javascript - 通过javascript将鼠标悬停添加到链接

标签 javascript hyperlink onmouseover

简单快速的问题....

我有以下链接 html:

<a href="http://www.site.com/" onmouseover="" />

我有一个 javascript 函数,我想在该链接中动态输入一些 onmouseover 信息。因此,如果调用此 javascript 函数,那么假设它变成这样:

<a href="http://www.site.com/" onmouseover="alert('howdy')" />

有什么办法吗?

最佳答案

添加name属性并赋值onmouseover

<a href="http://www.site.com/" onmouseover="" name="xxx"/> 
document.getelementsbyname('xxx').onmouseover = function() { alert('howdy') } 

关于javascript - 通过javascript将鼠标悬停添加到链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4873582/

相关文章:

javascript - 使用 JQuery/Javascript 进行动态 HTML 值计算

html - Thymeleaf:可点击的行

javascript - imagemap onMouseOver解决方案

javascript - 渐变颜色 OnMouseOver(禁用样式颜色)???

Javascript 循环调用函数

javascript - 使用 mocha/chai 测试几个函数回调

javascript - 大多数 Flash 游戏无法在浏览器窗口中正确调整大小。我怎样才能轻松地让我的游戏做到这一点?

javascript - 使用位置 : 'Absolute' and display: 'None' in React Native still renders the component

javascript - 目标 ="_blank"中的下划线是否不再需要?

c# - Creating Hyperlink in Dynamically Created Table 错误 'Table' cannot have children of type 'HyperLink' 。