I am trying to accomplish what the jQuery live() function can do, but in plain JavaScript. Can anyone here help with this?
Thanks!
Here is a little startup example
document.onclick = function(evt){
evt = evt || window.event;
var element = evt.target || evt.srcElement;
};
wherever you click you get a reference to the element that received the click.
More useful, though, in a real scenario would be to use the attachEvent
method for IE, or the addEventListener
for the rest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With