Created
October 17, 2014 07:47
-
-
Save RCmerci/5998a87a5d914adfbf6a to your computer and use it in GitHub Desktop.
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
for (var i = 0; i < divs.length; i++) { | |
divs[i].addEventListener("click", function() { | |
alert("divs #" + i + " was clicked."); | |
}, false); | |
} | |
//这里的i被closure了,每次循环会被更新,而不是当时的值 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment