P

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

· 8년 전 · 3274

 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,916
jQuery 8년 전 조회 1,980
jQuery 8년 전 조회 1,806
jQuery 8년 전 조회 2,773
PHP 8년 전 조회 2,048
PHP 8년 전 조회 1,897
PHP 8년 전 조회 2,066
기타 8년 전 조회 1.6만
OS 8년 전 조회 3,150
jQuery 8년 전 조회 2,213
jQuery 8년 전 조회 2,306
jQuery 8년 전 조회 2,425
jQuery 8년 전 조회 2,192
jQuery 8년 전 조회 2,343
jQuery 8년 전 조회 3,275
PHP 8년 전 조회 2,196
PHP 8년 전 조회 1,980
PHP 8년 전 조회 2,263
PHP 8년 전 조회 2,008
PHP 8년 전 조회 2,707
PHP 8년 전 조회 2,405
jQuery 8년 전 조회 2,353
jQuery 8년 전 조회 2,465
jQuery 8년 전 조회 1,854
jQuery 8년 전 조회 1,884
jQuery 8년 전 조회 1,887
jQuery 8년 전 조회 2,277
PHP 8년 전 조회 2,392
PHP 8년 전 조회 2,260
PHP 8년 전 조회 2,499