Why when childNodes is used, text and comment reutrns?

489 Views Asked by At

When i use childnode it also return, text and column and then it starts the element. Can some explain why it does that?

1

There are 1 best solutions below

0
Jacob On BEST ANSWER

Per the MDN docs (emphasis mine):

It is important to keep in mind that childNodes includes all child nodes, including non-element nodes like text and comment. To get a collection containing only elements, use Element.children instead.