html:
<div class="c">
<div id="b" class="b" style="width: 200px; height: 200px; background: green;"></div>
</div>
<input type="button" id="a" class="a" value="按钮"/>
js:
$('.b').on('mouseenter',function(){
alert(123);
})
$('.a').on('click',function(){
//$('#b').off('mouseenter');
var $b = $('.c').children('.b');
$b.off('mouseenter');
})
由此说明,一个元素的事件,不管通过什么途径获取它(只要获取这个元素),就可以解绑事件。
同意吗?
网友评论