Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Last active March 31, 2023 17:38
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonewebdesign/4017724 to your computer and use it in GitHub Desktop.
Save simonewebdesign/4017724 to your computer and use it in GitHub Desktop.
<button id="btn">Click me!</button>
<script>
var btn = document.getElementById('btn');
btn.onclick = function() {
// will be overwritten!
console.log('[onclick] foo');
}
btn.onclick = function() {
console.log('[onclick] bar');
}
btn.addEventListener('click', function() {
// won't work on IE < 9
console.log('[EventListener] foo');
});
btn.addEventListener('click', function() {
// won't work on IE < 9
console.log('[EventListener] bar');
});
</script>
@Snawley
Copy link

Snawley commented Nov 24, 2019

super clear

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