P

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

· 8년 전 · 3356

 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에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 8년 전 조회 1,993
jQuery 8년 전 조회 2,060
jQuery 8년 전 조회 1,890
jQuery 8년 전 조회 2,851
PHP 8년 전 조회 2,127
PHP 8년 전 조회 1,984
PHP 8년 전 조회 2,149
기타 8년 전 조회 1.6만
OS 8년 전 조회 3,237
jQuery 8년 전 조회 2,312
jQuery 8년 전 조회 2,392
jQuery 8년 전 조회 2,508
jQuery 8년 전 조회 2,277
jQuery 8년 전 조회 2,428
jQuery 8년 전 조회 3,357
PHP 8년 전 조회 2,282
PHP 8년 전 조회 2,059
PHP 8년 전 조회 2,344
PHP 8년 전 조회 2,085
PHP 8년 전 조회 2,748
PHP 8년 전 조회 2,453
jQuery 8년 전 조회 2,429
jQuery 8년 전 조회 2,548
jQuery 8년 전 조회 1,950
jQuery 8년 전 조회 1,971
jQuery 8년 전 조회 1,968
jQuery 8년 전 조회 2,351
PHP 9년 전 조회 2,482
PHP 9년 전 조회 2,339
PHP 9년 전 조회 2,575