7 JavaScript Things I Wish I Knew Much Earlier In My Career — Smashing Magazine

This could also be done with a single event handler:(function(){ var resources = document.getElementById(‘resources’); resources.addEventListener(‘click’,handler,false); function handler(e){ var x = e.target; // get the link tha if(x.nodeName.toLowerCase() === ‘a’){ alert(‘Event delegation:’ + x); e.preventDefault(); } };})();CopyBecause the click happens on all the elements in the list, all you need to do is compare the nodeName…