Skip to content

Instantly share code, notes, and snippets.

@duhaime
Created March 1, 2017 17:20
Show Gist options
  • Select an option

  • Save duhaime/b7f3876bc2cbe27e9fd42fd47f1a1beb to your computer and use it in GitHub Desktop.

Select an option

Save duhaime/b7f3876bc2cbe27e9fd42fd47f1a1beb to your computer and use it in GitHub Desktop.
document.querySelectorAll('*').forEach(
function(i) {
i.addEventListener('click', function(e){
console.log(e.target)
})
}
)
@ifyour

ifyour commented Mar 1, 2017

Copy link
Copy Markdown
document.querySelectorAll('*').forEach(
      function(i) {
        i.addEventListener('click', function(e) {
          console.log(e.target);
          e.stopPropagation(); // only get current target DOM :P
        });
      }
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment