Events - Unbind() 메서드 (이벤트 처리기 해제)
.NET프로그래밍/jQuery 1.3.2 2009. 11. 12. 08:29 |
[Unbind.htm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>이벤트 처리기 해제</title>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
//[!] 버튼 클릭시 메시지 출력
$('#btn').click(function () { alert('클릭됨'); });
//[1] unbind() 메서드로 지정된 이벤트 해제
$('#btnUnbind').one("click", function () {
$('#btn').unbind("click"); // 바인딩 해제
});
});
</script>
</head>
<body>
<div id="my">
<input type="button" id="btn" value="버튼" class="hover" />
<input type="button" id="btnUnbind" value="이벤트 해제" class="hover" />
</div>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]
--> 왼쪽에 있는 '버튼'을 클릭했을때의 화면
--> 오른쪽에 있는 '이벤트 해제'버튼을 먼저 클릭한 후 왼쪽의 '버튼'을 클릭하였을 때의 화면.(바인드가 해제(-> Unbind)되어서 위의 그림처럼 'click'이벤트로 발생하는 메시지박스가 출력되지 않는다.)
'.NET프로그래밍 > jQuery 1.3.2' 카테고리의 다른 글
Effects - FadeIn() / FadeOut() 메서드 (서서히 보이기 및 숨기기) (0) | 2009.11.12 |
---|---|
Effects - Show() / Hide() 메서드 (보이기 및 숨기기) (0) | 2009.11.12 |
Events - Trigger() 메서드 (동적으로 다른 이벤트 호출) (0) | 2009.11.12 |
CSS - OuterWidth() / OuterHeight() 메서드 (검색된 요소의 크기 구하기) (0) | 2009.11.11 |
CSS - Width() / Height() 메서드 (검색된 요소의 크기 구하기) (0) | 2009.11.11 |