loop through elements of class code example
Example 1: javascript loop through class elements
var els = document.getElementsByClassName("myClass");
for(var i = 0; i < els.length; i++)
{
console.log(els[i]);
}
Example 2: jquery loop over elements
$( "li" ).each(function( index ) {
console.log( index + ": " + $( this ).text() );
});
Example 3: jquery loop through li elements
//looping through list elements in jquery
$('#myUlID li').each(function() {
console.log($(this));
})