Skip to content

Instantly share code, notes, and snippets.

@deweller
Created January 20, 2011 17:40
Show Gist options
  • Save deweller/788249 to your computer and use it in GitHub Desktop.
Save deweller/788249 to your computer and use it in GitHub Desktop.
<html>
<body>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
</body>
<script type="text/javascript">
els = document.getElementsByTagName('li');
for(var i=0; i < els.length; i++){
els[i].addEventListener('click', function(){alert(i);}, false);
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment