js for each element with class code example
Example 1: jquery loop over elements
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
Example 2: jquery loop through li elements
$('#myUlID li').each(function() {
console.log($(this));
})
Example 3: foreach element in class javascript
var slides = getElementsByClassName("slide");
for(var i = 0; i < slides.length; i++)
{
Distribute(slides[i]);
}
Example 4: javascrip for each element of class
var slides = document.getElementsByClassName("slide");
for (var i = 0; i < slides.length; i++) {
Distribute(slides.item(i));
}