반응형
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
//off는 unbind랑 비슷한듯?
$(document).ready(function() {
$("p").on("click", function() {
$(this).css("background-color", "red");
});
$("button").click(function() {
$("p").off("click");
});
});
</script>
<title>Document</title>
</head>
<body>
<p>Click this paragraph to change its background color</p>
<p>
Click the button below and then click on this paragraph.(the click event
is removed)
</p>
<br />
<button>이벤트제거(off)</button>
</body>
</html>
반응형
'2020 > JQuery' 카테고리의 다른 글
JQuery FadeIn(), FadeOut() (0) | 2020.03.01 |
---|---|
Jquery slideDown(), slideUp() (0) | 2020.03.01 |
JQuery insertAfter, insertBefore 요소추가 (0) | 2020.02.29 |
JQuery 요소 추가(형제관계) (0) | 2020.02.29 |
JQuery 요소 감싸기, 요소 태그 넣기 (0) | 2020.02.29 |