Skip to content Skip to sidebar Skip to footer

Haschildnodes() Does Not Work

I have a tree view and a delete button on the webpage. The tree view loads with parent nodes and child nodes. If I click on delete after selecting a parent node with child nodes, i

Solution 1:

Try checking

var hasChilds = selectedNode.children.length > 0;

This will check for elements instead of childNodes which will check for elements and text nodes, which can come from whitespace in your markup.

Post a Comment for "Haschildnodes() Does Not Work"