移除/取消绑定悬停在锚点上 [英] remove/unbind hover on anchors
本文介绍了移除/取消绑定悬停在锚点上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
html
<a href="home.html">Home</a>
css
a {
color: blue;
}
a:hover {
color: red;
}
现在您可以看到< a>
现在悬停时会出现红色。
now as you can see <a>
now would be color red on hover.
问题
如何删除悬停jQuery?
我试过:
$('a')。unbind('hover');
和 $('a')。unbind('mouseenter mouseleave')
我想到为什么它不起作用,这是不是 hover()
?
I come to think why it won't work, is this not hover()
?
推荐答案
由于 a:hover
不是锚标记上的绑定事件,只是一个伪类,你不会成功取消绑定.hover()事件。
Since a:hover
is not bound event on the anchor tag and is only a pseudo class you won't have success unbinding the .hover() event.
如果你想改变行为,你可以做两件事
If you want to change the behavior then you can do two things
-
删除
a :hover
styles
在锚标记上绑定悬停事件并相应地设置css。
bind a hover event on the anchor tag and set the css accordingly.
这篇关于移除/取消绑定悬停在锚点上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文