如何使用 jquery 在通常使用 css 完成的链接上实现悬停效果:hover 来更改链接的颜色
如何使用 jquery 在通常使用 css :hover 关闭的链接上实现悬停效果,因此当我将鼠标悬停在链接上时,它会更改为不同的颜色,当我的鼠标离开链接时,它会返回到之前的颜色?
编辑 我的链接有一个设置其颜色的内联样式,所以我尝试添加和删除类,但它们不起作用,似乎新添加的 css 类无法覆盖内联样式。
How do I use jquery to achieve hover effect on a link that is normally down with css :hover, so when I hover over a link it changes to a different color, and when my mouse leaves the link it returns to the color it had before?
Edit
My link has an inline style that sets its color, so I tried add and remove class they don't work, it seems the newly added css class cannot override the inline style.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个简单的方法就是使用
jQuery.hover()
:或者
A simple way just use
jQuery.hover()
:or
使用 mouseenter 和 mouseleave 事件。
mouseover、mouseout 也可以工作。
对于链接,您可以使用带有 # 的 id 或带有 .
所以
这样你就可以使用;
或者
use the mouseenter and mouseleave events.
mouseover, mouseout will also work.
for the link you can use the id with the # or class name with the .
so
so you can then use;
or