become 3 and sometimes 8?
val = list.childNodes;
Comment is 8 but when you look at the console, it now turns up as 3?
what do you mean comment
When you do val = list.childNodes; console.log(val); And after you add a comment in HTML page and do this val = list.childNodes; console.log(val); The NodeList turns out to add another 2. And when you check out the node type of 3, val = list.childNodes; val = list.childNodes[0]; val = list.childNodes[0].nodeName; val = list.childNodes[3].nodeType; console.log(val); It now turns up 8.
So I’m wondering why just adding a comment in HTML page, the NodeList adds another 2 by just checking out childNodes[3].nodeType;
It probably adds 2 nodes because one is the comment node and the other is the whitespace after it
In a HTML page, </li> <! — Comment —> <li class=“collection-item”> Is just adding the comment in between </li> and <li> considered adding whitespace too?
You added newlines!
Обсуждают сегодня