Question

I looked through documentation and there seems to be no way to get an array of children of a given node...

something like

 if (parentNode.hasChildren() == true) {
        alert('yay');

        if (parentNode.children == null) {
            alert('what the???');
        }
 }

this code will output 'yay', (i use a node that has children) but parentNode.children is null because 'what the??' is also being output....

Is there any way to get an array of children of a particular node?

In the case above, i would expect the parentNode to have an array of children, but there seems to be no way to get the children, only add and remove them.

Is my understanding correct?

Was it helpful?

Solution

It's parentNode.childList

OTHER TIPS

try to use

parentNode.children()

jQuery children API

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top