从 <a>
获取地址值的最佳方法是什么使用 onmouseover 事件标记?
<a href="http://facebook.com" onmouseover="">something</a>
最佳答案
<a href="http://facebook.com" onmouseover="alert(this.getAttribute('href'))">something</a>
您可以使用以下代码将此结果存储在变量中:
document.getElementsByTagName('a')[0].onmouseover = function() {
var hrefValue = this.getAttribute('href');
alert(hrefValue); // use hrefValue
}
关于javascript - 使用 onmouseover 获取地址时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33476879/