Answers for "how to get the element of all child js"

0

select all children javascript

/* SELECT using PARENT.childNodes */
let allChildren = document.querySelector("#parentSelector").childNodes

/* PRINT */
for(let i=0; i < allChildren.length; i++) {
         console.log("Child #", i + 1, allChildren[i])
}
Posted by: Guest on July-17-2021
2

get all the child of the same class javascript

var doc = document.getElementById("test");
var notes = null;
for (var i = 0; i < doc.childNodes.length; i++) {
    if (doc.childNodes[i].className == "4") {
      notes = doc.childNodes[i];
      break;
    }        
}
Posted by: Guest on February-13-2020

Code answers related to "how to get the element of all child js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language