Created
January 20, 2012 12:49
-
-
Save yasu/1647225 to your computer and use it in GitHub Desktop.
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
| // Make a function that assigns event handler functions to an array of nodes the right way. | |
| // When you click on a node, an alert box will display the ordinal of the node. | |
| var add_the_handlers = function (nodes) { | |
| var i; | |
| for (i = 0; i < nodes.length; i += 1) { | |
| nodes[i].onclick = function (i) { | |
| return function (e) { | |
| alert(i); | |
| }; | |
| }(i); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment