jQuery unbind('hover')不起作用 [英] jQuery unbind('hover') does not work
本文介绍了jQuery unbind('hover')不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的解绑不起作用。
$("img.hoverable").hover(ChangeImage, ChangeBack);
$("a img.hoverable").unbind('hover');
HTML可能是这样的
The HTML could be like this
<img class="hoverable" src="something.jpg"/>
<a href="#"><img class="hoverable" src="something.jpg"/></a>
当我将鼠标悬停在第二个HTML上时,仍会触发ChangeImage。
When I hover over the second HTML, ChangeImage is still fired.
我不确定我是否正确使用它,有人可以提供建议吗?
I am not sure if I am using it correctly, can anyone please advise?
推荐答案
试试
$("img.hoverable").unbind('mouseenter mouseleave');
.hover()方法为mouseenter和mouseleave事件绑定处理程序。所以为了解开绑定,你必须解开mouseenter和mouseleave。
The .hover() method binds handlers for both mouseenter and mouseleave events. So inorder to unbind you will have to unbind mouseenter and mouseleave.
这篇关于jQuery unbind('hover')不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文