Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Created October 15, 2020 19:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleMit/2ed53e91fbd65c1e72f604f59e9024a6 to your computer and use it in GitHub Desktop.
Save KyleMit/2ed53e91fbd65c1e72f604f59e9024a6 to your computer and use it in GitHub Desktop.
Twitter - Delegated Listener
$("body").on("click", ".rectangle", function(e) {
console.log("jquery", this)
// do stuff
});
document.body.addEventListener("click", e => {
if (e.target.matches(".rectangle")) {
console.log("vanilla", e.target);
// do stuff
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment