jQuery w3schools 한글판 강좌23 - Commonly Used jQuery Event Methods - on() 메소드 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

jQuery w3schools 한글판 강좌23 - Commonly Used jQuery Event Methods - on() 메소드 정보

jQuery jQuery w3schools 한글판 강좌23 - Commonly Used jQuery Event Methods - on() 메소드

본문

 jQuery w3schools 한글판 강좌23 - Commonly Used jQuery Event Methods - on() 메소드

 

The on() Method

on() 메소드는 선택된 요소들에 대한 한개 이상의 이벤트 핸들러를 붙여준다

 

click 이벤트를  한개의 <p>요소에 붙이는 예:

 

Example

$("p").on("click", function(){
    $(this).hide();
});

여러개의 이벤트 핸들러를 한개의 요소에 붙이는 예:

 

Example

$("p").on({
    mouseenter: function(){
        $(this).css("background-color", "lightgray");
    }, 
    mouseleave: function(){
        $(this).css("background-color", "lightblue");
    }, 
    click: function(){
        $(this).css("background-color", "yellow");
    } 
});

 

 

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로