Skip to content

Instantly share code, notes, and snippets.

@tschmidt
Created April 7, 2011 16:03
Show Gist options
  • Save tschmidt/908078 to your computer and use it in GitHub Desktop.
Save tschmidt/908078 to your computer and use it in GitHub Desktop.
DOM Events
// Answer 1
document.getElementById('the_div').addEventListener(
'click', function(){ log('the_div!') }, true);
document.getElementById('the_list').addEventListener(
'click', function(){ log('the_list!') }, false);
document.getElementById('the_item').addEventListener(
'click', function(){ log('the_item!') }, false);
// Answer 2
document.getElementById('the_div').addEventListener(
'click', function(){ log('the_div!') }, false);
document.getElementById('the_list').addEventListener(
'click', function(){ log('the_list!') }, false);
document.getElementById('the_item').addEventListener(
'click', function(){ log('the_item!') }, false);
// Answer 3
document.getElementById('the_div').addEventListener(
'click', function(){ log('the_div!') }, false);
document.getElementById('the_list').addEventListener(
'click', function(){ log('the_list!') }, false);
document.getElementById('the_item').addEventListener(
'click', function(event){ log('the_item!'); event.stopPropagation(); }, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment