Reputation: 63
Javascript .children.length()
returns wrong value i.e. 0 while if I use .firstNode then there is a text node available.
Please help me out in this.
Many thanks
Upvotes: 1
Views: 1318
Reputation: 664620
The .children
collection doesn't include text nodes, but only elements. You might be looking for .childNodes.length
or simply .hasChildNodes()
instead.
Upvotes: 1