Skip to content

Instantly share code, notes, and snippets.

@Huskie
Created January 23, 2014 14:43
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 Huskie/8579597 to your computer and use it in GitHub Desktop.
Save Huskie/8579597 to your computer and use it in GitHub Desktop.
A standard for loop given a variable named 'elements', which contains a Node List of HTML elements, likely returned from a 'document.querySelectorAll' statement.
// Given a variable 'elements', which contains a Node List of HTML elements
for ( var i = 0; i < elements.length; i++ ) {
var self = elements[i];
// Do stuff with element
self.doStuff();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment