ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Javascript Event, 이벤트 처리기
    Search: Html Css JavaScript Html Css JavaScript 2022. 11. 16. 18:09

    Javascript Event, 이벤트 처리기

     

    <body onload='alert("load complete");'>
    <p id="text1id"> text1 </p>
    <p id="text2id"> [지금창 닫기] </p>
    <script>
      var t1obj = document.querySelector('#text1id');
      t1obj.onclick = ()=>{ document.querySelector('#text1id').style.color = "red"; };
      var t2o = document.querySelector('#text2id');
      t2o.onclick = ()=>{ javascript:window.close(); };
    </script>
    </body>

    text1

    [지금창 닫기]

     

    마우스 이벤트

    click, onclick:

    dbclick, ondbclick

    mouseup, onmouseup: 사용자가 요소 위에 누른 마우스 버튼을 올릴 때 이벤트가 발생한다.

    mosedown, onmosedown:

    mousemove, onmousemove: 

    mouseover, onmouseover: 마우스 포인터가 요소 위로 옮겨질 때 이벤트가 발생한다.

    mouseout, onmouseout: 마우스 포인터가 요소를 벗어날 때 이벤트가 발생한다.

     

    키보드 이벤트

    keydown, onkeydown

    keypress, onkeypress

    keyup, onkeyup

     

    문서 로딩 이벤트

    abort, onabort: 문서가 완전히 로딩되기 전에 불러오기를 멈췄을 때 발생.

    error, onerror: 로딩되지 않았을 때 발생.

    load, onload: 로딩이 끝나면 발생.

    resize, onresize: 화면 크기가 바뀌었을 때 발생.

    scroll, onscroll: 화면이 스크롤되었을 때 발생.

    unload, onunload: 문서에서 벗어날 때 발생.

     

    폼 이벤트

    사용자 입력, 검색, 설문조사 등 사용자 입력의 모든 요소

    blur, onblur: 포커스를 잃었을 때 발생.

    change, onchange: 변경되었을 때 발생. <input>, <select>, <textarea>

    focus, onfocus: 포커스가 놓였을 때 발생. <label>, <select>, <textarea>, <button>

    reset, onreset: 폼이 리셋되었을 때 발생.

    submit, onsubmit: submit버튼을 클릭했을 때 발생.

     

     

    댓글