0
Dom
What's the meanings of child node
3 Answers
+ 6
tags that starts and ends within an another tag is called child node
eg: <body> tag has a child <p> and <h1>
+ 3
Thanks so Much
+ 2
function setText() {
var a = document.getElementById("demo");
console.log(a);
if(a != null && a.hasChildNodes()){
var arr = a.childNodes;
for(var x=0;x<arr.length;x++) {
arr[x].innerHTML = "new text";
}
} else {
alert(" No Child Nodes");
}
}
//calling the function with setTimeout to make sure the HTML is loaded
setTimeout(setText, 500);