Behind The Web Page
Behind The Web Page

Reputation: 103

Why when childNodes is used, text and comment reutrns?

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

Upvotes: 0

Views: 634

Answers (1)

Jacob
Jacob

Reputation: 1835

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.

Upvotes: 1

Related Questions