for each child element javascript code example
Example: for each child of element
const secondaryNavList = document.querySelector('.navigation__secondary');
const secondaryNavListChildren = Array.from(secondaryNavList.children);
for (let secondaryNavListItem of secondaryNavListChildren) {
console.log(secondaryNavListItem);
}
const secondaryNavListChildren = Array.prototype.slice.call(secondaryNavList.children);
for (let secondaryNavListItem of secondaryNavListChildren) {
console.log(secondaryNavListItem);
}
const secondaryNavListChildren = secondaryNavList.childNodes;
secondaryNavListChildren.forEach((navListItem) => {
console.log(navListItem);
})