Created
August 18, 2012 15:13
-
-
Save ekka21/3387434 to your computer and use it in GitHub Desktop.
Javascript: e.preventDefault()
This file contains hidden or 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
var normal = document.querySelector('.normal'), | |
prevent = document.querySelector('.prevent'); | |
prevent.addEventListener('click', function(ev) { | |
alert('fabulous, really!'); | |
ev.preventDefault(); | |
}, false); | |
normal.addEventListener('click', function(ev) { | |
alert('fabulous, really!'); | |
}, false); |
This file contains hidden or 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
var normal = document.querySelector('.normal'), | |
prevent = document.querySelector('.prevent'); | |
prevent.addEventListener('click', function(ev) { | |
alert('fabulous, really!'); | |
ev.preventDefault(); | |
}, false); | |
normal.addEventListener('click', function(ev) { | |
alert('fabulous, really!'); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment