Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Gov.uk drops jQuery from their front end. Parent comment
document.addEventListener('click', function(e){ var t = e.target;
if(t.closest('.foo') && t.nodeName.toLowerCase() === 'button'){ e.preventDefault(); // do stuff here } else if(t.closest('.bar') && t.nodeName.toLowerCase() === 'a' && t.classList.contains('here')){ e.preventDefault(); // do smth else here }
one listener to rule them all...?
elegant enough and once you get used to it...
.closest can be pollyfilled too..
There are no comments on this comment yet.
document.addEventListener('click', function(e){ var t = e.target;
}, false);one listener to rule them all...?
elegant enough and once you get used to it...
.closest can be pollyfilled too..