javascriptjqueryjstreejstree-searchjstree-dnd

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.


Solution

  • This is how I solved my problem

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