How can I get only the direct children of a node?
More context would be helpful, but .children()?
Ok, my problem is that children () returns all descendants of a node, the full hierarchy, while I want to check only the immediate children, i.e., the nodes on the next level at the tree.
@lhsantos .children() should only return the direct children; but those themselves have their own children. Can you step back a bit and explain what you're trying to check for?
Well, for instance, I called root.children('ul') and it returned the immediate child that's a 'ul', but also a grandchild of that node that's also a 'ul'.
try root.children().filter(‘ul’)
ok, sorry for the late response. i'm not completely sure of what i was doing wrong, but i think now i understand how this works. thanks!
Most helpful comment
try
root.children().filter(‘ul’)