11.jQuery - Click 클릭이벤트 ( 11.Click )
bind() 중 click 이벤트는 click() 메서드로 사용
사용빈도가 높은 Click(클릭) 이벤트 사용 예제입니다.
[ 아이디 값에 따라 각각의 이벤트 처리 ]
11.Click.htm |
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>bind() 중 click 이벤트는 click() 메서드로 사용</title> <style type="text/css"> .redColor { color:Red; } </style> <script src="jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { //특정 요소에 클릭 이벤트를 적용 : bind() 보다 간편 $('#mainMenu .redColor').click(function() { if (this.id == "dnk") { location.href = "http://www.dotnetkorea.com"; } else if (this.id == "godffs") { window.open("http://godffs.tistory.com", "", ""); } }); }); </script> </head> <body> <div id="mainMenu"> <div id="dnk" class="redColor">닷넷코리아</div> <div id="godffs" class="redColor">준철이 블로그</div> <div id="ll" class="redColor">라이선스랜드</div> </div> </body> </html> |
결과화면 |
