테스트 사이트 - 개발 중인 베타 버전입니다

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

· 8년 전 · 3182

 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");
    } 
});

 

 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시판 목록

개발자팁

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