Skip to content

Instantly share code, notes, and snippets.

@hoatle
Created February 3, 2012 07:13
Show Gist options
  • Save hoatle/1728663 to your computer and use it in GitHub Desktop.
Save hoatle/1728663 to your computer and use it in GitHub Desktop.
js closure usage
for (var i = 0; i < this.allCommentSize; i++) {
(function(i) {
//when this element is displayed
if (uiActivity.commentBlockEls[i]) {
Util.addEventListener(uiActivity.commentBlockEls[i], ['mouseover', 'focus'], function(evt) {
uiActivity.deleteCommentButtonEls[i].className = 'CloseContentBoxHilight';
}, false);
Util.addEventListener(uiActivity.commentBlockEls[i], ['mouseout', 'blur'], function(evt) {
uiActivity.deleteCommentButtonEls[i].className = 'CloseContentBoxNormal';
}, false);
}
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment