+ 4
[SOLVED] Avoiding undefined childNodes
Can I know how to avoid undefined childNodes? https://code.sololearn.com/W5Xp79DKiKH4/?ref=app
2 Respuestas
+ 6
childNode would include textNode and comment, use children instead.
https://code.sololearn.com/WuSlnqPIv3qD/?ref=app
+ 4
You can follow what Calviղ told. His approach is best
Or you can do as follow :
//code snippet
for (var i=0;i<document.getElementById("myDIV").children.length;i++)
{
if(typeof(document.getElementById("myDIV").children[i] != undefined))
{
//your code here
}
}