Last active
June 8, 2018 15:42
-
-
Save juanbrujo/094cd486e6d77f040bff to your computer and use it in GitHub Desktop.
looping through querySelectorAll elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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