Skip to content

Instantly share code, notes, and snippets.

@bcherry
Created February 17, 2010 02:15
Show Gist options
  • Save bcherry/306210 to your computer and use it in GitHub Desktop.
Save bcherry/306210 to your computer and use it in GitHub Desktop.
var ids = ["elem1", "elem2", "elem3"...],
i,
l = ids.length;
for (i = 0; i < l; i += 1) {
(function (i) {
$("#" + ids[i]).bind("click", function () {
alert(i);
});
}());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment