Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created April 16, 2013 02:10
Show Gist options
  • Save bittersweetryan/5392810 to your computer and use it in GitHub Desktop.
Save bittersweetryan/5392810 to your computer and use it in GitHub Desktop.
;(function(){
var anchor = document.querySelectorAll( 'a' )[0],
span = document.querySelectorAll( 'span' )[0],
div = document.querySelectorAll( 'div' )[0];
div.addEventListener( 'click', function( e ){
console.log( e.target, e.currentTarget ); //anchor, div
e.preventDefault();
});
span.addEventListener( 'click', function( e ){
console.log( e.target, e.currentTarget ); //anchor, span
e.preventDefault();
});
anchor.addEventListener( 'click', function( e ){
console.log( e.target, e.currentTarget ); //anchor, anchor
e.preventDefault();
});
document.addEventListener( 'click', function( e ){
console.log( e.target, e.currentTarget ); //anchor, document
e.preventDefault();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment