Created
October 15, 2020 19:54
-
-
Save KyleMit/2ed53e91fbd65c1e72f604f59e9024a6 to your computer and use it in GitHub Desktop.
Twitter - Delegated Listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("body").on("click", ".rectangle", function(e) { | |
console.log("jquery", this) | |
// do stuff | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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