KnowledgeOverflow KnowledgeOverflow - 1 month ago 7
Javascript Question

How to loop over all the nodes of a jstree

I am unable to figure out how I can loop over all the nodes of a jstree.

What I am looking for is that for the jstree

jstree1
. I want to loop over all of its children and sub-children and print/get the
id
of each leaf.

Thanks.

Answer

This is how I solved my problem

$(function () {
    $.each($("#jstree1").jstree('full').find("li"), function (index, element) 
    {
        console.log($(element));
    });
});