如何删除:hover? [英] How do I remove :hover?
问题描述
我的脚本有一个小问题。
对于禁用Javascript的客户端,我想对:hover
进行默认操作,但对于那些启用了Javascript的用户,我想要另一个操作(实际上是...相同的操作,但是我想添加一个小的过渡效果)。
I have a small problem with a script.
I want to have a default action on :hover
for clients with Javascript disabled, but for those with Javascript enabled I want another action (actually... same action, but I want to add a small transition effect).
所以...我该怎么办这个?我正在使用jQuery。
So... How can I do this? I am using jQuery.
推荐答案
将两个类应用于relvant元素。一个包含悬停行为,一个包含所有其他样式。
Apply two classes to the relvant element. one contains the hover behaviour, and one contains all the other styling.
然后可以使用jquery
You can then use the jquery
$(element).removeClass('hover');
方法可删除具有悬停行为的类,然后使用
method to remove the class with the hover behaviour and then apply whatever you want using
$(element).bind('mouseover', function () { doSomething(); });
$(element).bind('mouseout', function () { doSomething(); });
这篇关于如何删除:hover?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!