javascript - document.activeElement.href not working in chrome -


i used document.activeelement.href target location of clicked tag. worked property in firefox, not working in chrome.

i want "href" location of clicked(active) element in other function outside of it.

like this:

function animate() {     alert(document.activeelement.href); //not working in chrome }); 

thanks alot

edit : remember dont want use "this" or $(this) because doesn't work in function outside of element. know can use onclick="...." use "$(this)" each element dont want this.

my question simple:

can clicked(active) elementid in function outside of it? (except in firefox)

here solution using addeventlistener vanilla js

document.addeventlistener('click', function (e) {     var elm = e.target;     if (elm && elm.nodetype === 1 && elm.nodename === 'a') {         alert(elm.href);     } }); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -