Skip to content

Instantly share code, notes, and snippets.

@ekka21
Created August 18, 2012 15:13
Show Gist options
  • Save ekka21/3387434 to your computer and use it in GitHub Desktop.
Save ekka21/3387434 to your computer and use it in GitHub Desktop.
Javascript: e.preventDefault()
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);
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