Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var els = document.getElementsByClassName("myclass"); // Creates an HTMLObjectList not an array.
- Array.prototype.forEach.call(els, function(el) {
- // Do stuff here
- console.log(el.tagName);
- });
- // Or
- [].forEach.call(els, function (el) {...}); // Creates array on the fly.
Add Comment
Please, Sign In to add comment