[jQueyr] On / Off 이벤트
eventOn.html |
<!doctype html> <html lang="ko"> <head> <meta charset="UTF-8"> <title>ON 이벤트</title> <style type="text/css"> p { width:300px; height:50px; margin:0 auto; padding-top:25px; font-size:1em; text-align:center; border:1px solid black; } </style> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery("p").on({ click:function() { jQuery("p").css("background-color", "#FFFF00"); }, mouseover:function() { jQuery("p").css("background-color", "#87CEEB"); }, mouseout:function() { jQuery("p").css("background-color", "#FF0000"); } }); }); </script> </head> <body> <h1>이벤트 등록</h1> <hr/> <p>마우스를 클릭하거나 이동해 보세요.</p> </body> </html> |
출력결과01 - 기본화면 |
출력결과02 - 마우스가 BOX 영역을 벗어 났을때 |
출력결과02 - 마우스가 BOX 영역안으로 들어왔을때 |
출력결과03 - 마우스로 BOX 영역을 클릭했을때 |
eventOff.html |
<!doctype html> jQuery("#btn").off("click"); |
출력결과01 - '이벤트 등록' 버튼을 클릭한 경우 |
출력결과02 - '클릭해 보세요' 버튼을 클릭한 경우 |
출력결과03 - '이벤트 제거' 버튼을 클릭한 경우 |
※ jQuery는 내부에 있는 함수도 호출 할 수 있다.
'jQuery' 카테고리의 다른 글
[jQuery] 움직이는 이미지 (0) | 2016.01.03 |
---|---|
[jQuery] 무한 스크롤 이벤트 (0) | 2016.01.03 |
[jQuery] input 이벤트 (0) | 2015.12.29 |
[jQuery] checkbox 이벤트 (1) | 2015.12.29 |
[jQuery] jQuery 엘리먼트 (0) | 2015.12.28 |