Created
September 10, 2011 22:40
-
-
Save pragmaticobjects/1208897 to your computer and use it in GitHub Desktop.
Onclick in a loop problem
This file contains hidden or 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
| var myElements = [ /* DOM Collection */ ]; | |
| for (var i = 0; i < 100; ++i) { | |
| myElements[i].onclick = function() { | |
| alert( 'You clicked on: ' + i ); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment