문제

I used

var hyper=document.querySelectorAll("a")
 for (var i=0; i<hyper.length; i++)
 {
     hyper[i].onmouseover=function()
     {
            alert("hyperlink");
     }
 }

to alert on a hyperlink via a greasemonkey script. Now, I want to get the href of hyper[i] so that I can handle different url's.

I tried hyper[i].href, but it's not working. What's the code to do this?

도움이 되었습니까?

해결책

Use this.href, since you're in an event handler the this context refers to the element being moused over.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top