document.activeElement.href not working in chrome
javascript, jquery
Solution
Here is a solution using `addEventListener` from Vanilla JS
document.addEventListener('click', function (e) {
var elm = e.target;
if (elm && elm.nodeType === 1 && elm.nodeName === 'A') {
alert(elm.href);
}
});
Problem
I used `document.activeElement.href` for get target location of clicked tag. Its worked property in firefox, but not working in chrome. I want to get `"href"` location of a 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 i dont want to use "this" or $(this) because it doesn't work in a function outside of the element. I know i can use `onclick="...."` then use `"$(this)"` for each element but i dont want this. My question is simple: can i get clicked(active) elementID in a function outside of it? (Except in firefox)