Skip to content

Instantly share code, notes, and snippets.

@NicholasEli
Created February 27, 2017 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NicholasEli/89799c128500f93827c613476c610237 to your computer and use it in GitHub Desktop.
Save NicholasEli/89799c128500f93827c613476c610237 to your computer and use it in GitHub Desktop.
IE compatible for-loops and event attachments
//passing i to an anonymous self executing funtion will bind event handlers to DOM nodes from IE9 and up. Haven't checked for IE9 and below.
for (let i = 0; i < el.length; i++) {
(function(i){
el[i].addEventListener('click', (event) => {
});
})(i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment