Created
March 4, 2011 19:42
-
-
Save JamieMason/855576 to your computer and use it in GitHub Desktop.
javascriptmasterclass.com - DOM task 3
This file contains 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
<div id="the_div"> | |
<ul id="the_list"> | |
<li id="the_item">Click me!</li> | |
</ul> | |
</div> | |
<p id="log"></p> | |
<!-- | |
3. Change the addEventListener calls so that the events occur in the following order. | |
the_item! (no other events) | |
--> | |
<script type="text/javascript" charset="utf-8"> | |
function log(string){ | |
document.getElementById('log').innerHTML += (string + '<br/>'); | |
} | |
document.getElementById('the_div').addEventListener( | |
'click', function(){ log('the_div!') }, true); | |
document.getElementById('the_list').addEventListener( | |
'click', function(){ log('the_list!') }, true); | |
document.getElementById('the_item').addEventListener( | |
'click', function(e){ log('the_item!'); e.stopPropagation(); }, true); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment