◽ HTML & CSS & JS, jQuery

[JavaScript - 기능 - (9) ] .unbind('click') : 이전에 넣은 이벤트 빼기

See the Pen jQuery Unbind Namespace by UX Team (@UXTEAM) on CodePen.

빨간색 버튼을 누르면 초록색 버튼의 이벤트를 빼는 것이다. ( .unbind()함수를 쓰면 된다. )

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
======HTML======
<div id="wrapper" class="p-5">
   <button id="test" class="btn btn-outline-success">Test Message</button>
   <button id="unbind" class="btn btn-outline-danger">Unbind Test Message</button>
</div>
 
 
 
 
======JS======
$('#wrapper').on( "click.demo""#test"function() {
   console.log( alert('clicked') );
});
 
$('#wrapper').on('click''#unbind'function(){
   $('#wrapper').off('click.demo''#test');
})
 

 

푸터바