Skip to content

Instantly share code, notes, and snippets.

@lafikl
Created October 2, 2013 11:44
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 lafikl/6792467 to your computer and use it in GitHub Desktop.
Save lafikl/6792467 to your computer and use it in GitHub Desktop.
forEach support for document.querySelectorAll
// adding forEach to elements result from querySelectorAll
NodeList.prototype.forEach = Array.prototype.forEach;
HTMLCollection.prototype.forEach = Array.prototype.forEach;
document.querySelectorAll('a').forEach( function (element, index, array){
element.style.color = "red";
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment