Skip to content

Instantly share code, notes, and snippets.

@pragmaticobjects
Created September 10, 2011 23:06
Show Gist options
  • Select an option

  • Save pragmaticobjects/1208927 to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticobjects/1208927 to your computer and use it in GitHub Desktop.
Closure solution
for (var i = 0; i < 100; ++i) {
myElements[i].onclick = (function(n) {
return function() {
alert( 'You clicked on: ' + n );
};
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment