Skip to content

Instantly share code, notes, and snippets.

@lafikl lafikl/foreach.js
Created Oct 2, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.