P

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

· 8년 전 · 3353

 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,989
jQuery 8년 전 조회 2,053
jQuery 8년 전 조회 1,887
jQuery 8년 전 조회 2,849
PHP 8년 전 조회 2,125
PHP 8년 전 조회 1,981
PHP 8년 전 조회 2,144
기타 8년 전 조회 1.6만
OS 8년 전 조회 3,232
jQuery 8년 전 조회 2,310
jQuery 8년 전 조회 2,388
jQuery 8년 전 조회 2,504
jQuery 8년 전 조회 2,273
jQuery 8년 전 조회 2,423
jQuery 8년 전 조회 3,354
PHP 8년 전 조회 2,279
PHP 8년 전 조회 2,057
PHP 8년 전 조회 2,341
PHP 8년 전 조회 2,080
PHP 8년 전 조회 2,747
PHP 8년 전 조회 2,449
jQuery 8년 전 조회 2,425
jQuery 8년 전 조회 2,545
jQuery 8년 전 조회 1,947
jQuery 8년 전 조회 1,967
jQuery 8년 전 조회 1,966
jQuery 8년 전 조회 2,348
PHP 8년 전 조회 2,479
PHP 8년 전 조회 2,335
PHP 8년 전 조회 2,574