js loop through elements with 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 through each child element
$('#mydiv').children('input').each(function () {
alert(this.value);
});
Example 3: javascript loop over classlist
var myElements = document.getElementsByClassName("some_class_name");
for(var i = 0; i < myElements.length; i++){
console.log(myElements[i]);
}
Example 4: how to loop over dom objects javascript
Array.from($('.'+$( this ).attr('id'))).forEach(function(obj){
console.log(obj);
});