如何解绑jquery/javascript中的绑定事件?
How to unbind a bind event in jquery / javascript?
我在 mousemove
的 DIV 上附加了一个事件:
$('#graph-container').bind('mousemove', function(){
// something happens here
}
如何解绑?
谢谢!
您使用unbind
,例如:
$('#graph-container').unbind('mousemove');
该示例将从元素中删除 所有 jQuery 附加的 mousemove
处理程序。您可以通过使用与 bidn
相同的函数引用或使用 jQuery 的事件 "namespaces," more in the docs.
来仅删除特定的
我在 mousemove
的 DIV 上附加了一个事件:
$('#graph-container').bind('mousemove', function(){
// something happens here
}
如何解绑?
谢谢!
您使用unbind
,例如:
$('#graph-container').unbind('mousemove');
该示例将从元素中删除 所有 jQuery 附加的 mousemove
处理程序。您可以通过使用与 bidn
相同的函数引用或使用 jQuery 的事件 "namespaces," more in the docs.