javascript loop through dom objects code example
Example 1: javascript loop through object
Object.entries(obj).forEach(
([key, value]) => console.log(key, value)
);
Example 2: javascript looping through object
for (var property in object) {
if (object.hasOwnProperty(property)) {
}
}
Example 3: loop through dom elements javascript
var all = document.getElementsByTagName("*");
for (var i=0, max=all.length; i < max; i++) {
}
Example 4: javascript looping through object
const fruits = {
apple: 28,
orange: 17,
pear: 54,
}
const entries = Object.entries(fruits)
console.log(entries)
Example 5: how to loop over dom objects javascript
Array.from($('.'+$( this ).attr('id'))).forEach(function(obj){
console.log(obj);
});