js each element in dom code example
Example 1: foreach element in class javascript
var slides = getElementsByClassName("slide");
for(var i = 0; i < slides.length; i++)
{
Distribute(slides[i]);
}
Example 2: loop through dom elements javascript
//Loop thru DOM elements
var all = document.getElementsByTagName("*");
for (var i=0, max=all.length; i < max; i++) {
// Do something with the element here
}