P

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

· 8년 전 · 3263

 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,900
jQuery 8년 전 조회 1,977
jQuery 8년 전 조회 1,793
jQuery 8년 전 조회 2,765
PHP 8년 전 조회 2,039
PHP 8년 전 조회 1,887
PHP 8년 전 조회 2,058
기타 8년 전 조회 1.6만
OS 8년 전 조회 3,129
jQuery 8년 전 조회 2,203
jQuery 8년 전 조회 2,294
jQuery 8년 전 조회 2,412
jQuery 8년 전 조회 2,183
jQuery 8년 전 조회 2,336
jQuery 8년 전 조회 3,264
PHP 8년 전 조회 2,190
PHP 8년 전 조회 1,975
PHP 8년 전 조회 2,252
PHP 8년 전 조회 2,002
PHP 8년 전 조회 2,702
PHP 8년 전 조회 2,401
jQuery 8년 전 조회 2,342
jQuery 8년 전 조회 2,462
jQuery 8년 전 조회 1,849
jQuery 8년 전 조회 1,877
jQuery 8년 전 조회 1,881
jQuery 8년 전 조회 2,270
PHP 8년 전 조회 2,382
PHP 8년 전 조회 2,254
PHP 8년 전 조회 2,490