如何在jquery / javascript中取消绑定绑定事件?

时间:2015-03-25 15:34:17

标签: jquery bind

我在mousemove上附加了一个DIV事件:

 $('#graph-container').bind('mousemove', function(){ 
     // something happens here
 }

我如何解开它?

谢谢!

1 个答案:

答案 0 :(得分:3)

您使用unbind,例如:

$('#graph-container').unbind('mousemove');

该示例将从元素中删除所有 jQuery附加的mousemove处理程序。您可以使用与bidn相同的函数引用,或使用jQuery的事件"名称空间,"来删除特定的函数。 more in the docs

请注意,在任何模糊的现代版jQuery中,最新的API调用都是onoff

相关问题