gpt4 book ai didi

javascript - 使用 onmouseover 获取地址时出现问题

转载 作者:行者123 更新时间:2023-12-03 08:27:43 24 4
gpt4 key购买 nike

<a> 获取地址值的最佳方法是什么使用 onmouseover 事件标记?

<a href="http://facebook.com" onmouseover="">something</a>

最佳答案

<a href="http://facebook.com" onmouseover="alert(this.getAttribute('href'))">something</a>

Working demo.

您可以使用以下代码将此结果存储在变量中:

document.getElementsByTagName('a')[0].onmouseover = function() {
var hrefValue = this.getAttribute('href');
alert(hrefValue); // use hrefValue
}

Working demo.

关于javascript - 使用 onmouseover 获取地址时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33476879/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com