为页面中的所有 URL 附加 OnMouseOver 事件
我想为页面中的所有锚标记附加 OnMouseOver。但如果任何锚标记已经有 OnMouseOver,即使我不想替换它。我只想在那里添加我的事件处理程序。
我如何通过 Javascript 或 JQuery 实现它?
I want to attach OnMouseOver even for all the anchor tags in a page. But i if any of the anchor tags already has a OnMouseOver even i dont want to replace it. I just want to add my event handler there.
How can i achieve it through Javascript or JQuery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认行为是添加而不是替换事件,因此只需使用
。 mouseover()
,如下所示:在这里尝试一下。或者也许您在
.hover()
之后,例如,如果您有 颜色插件 或 jQuery UI 并且您想要为颜色设置动画:您可以给它在这里尝试一下
The default behavior is to add not replace an event, so just use
.mouseover()
, like this:Give it a try here. Or maybe you're after
.hover()
, for example if you had the color plugin or jQuery UI and you wanted to animate the color:You can give it a try here