Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Last active June 8, 2018 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanbrujo/094cd486e6d77f040bff to your computer and use it in GitHub Desktop.
Save juanbrujo/094cd486e6d77f040bff to your computer and use it in GitHub Desktop.
looping through querySelectorAll elements
var elem = document.querySelectorAll(element)
// IE8+
if (elem.length) {
for (var i = 0; i < elem.length; i++) {
elem[i] // iterate over this
}
}
// IE9+
if (elem.length) {
[].forEach.call(elem, function(e) {
e // iterate over this
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment