Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

click 이벤트

앨리먼트를 클릭할 때, 발생하는 이벤트를 처리한다.

예제 1

<p>paragraph</p>를 클릭하면 alert 메시지를 출력한다.
<p id="click">안녕하세요</p>
<script>
$("p[id=click]").click(function() {
  alert("You clicked a paragraph!")
});
</script>

테스트

안녕하세요.

멀티플 이벤트

두 개 이상의 이벤트를 처리하는 코드. click와 change 이벤트가 발생하면 콘솔 로그를 남긴다.
<input id="testinput" type=text size=10 value="joinc">
<script>
$( "input[id=testinput]" ).on(
    "click change",  // bind listeners for multiple events
    function() {
        console.log( "An input was clicked or changed!" )
    }
);
</script>