How do I get the id of the selected node in jsTree?

前端 未结 14 2425
北恋
北恋 2020-12-29 22:38

How can I get the id of the selected node in a jsTree?

function createNewNode() {
  alert(\'test\');
  var tree = $.tree.reference(\"#basic_html\");
  select         


        
14条回答
  •  情深已故
    2020-12-29 23:00

    In the most recent version of jsTree (checked at 3.3.3), you can do this to get an array of IDs:

    var ids = $('#tree').jstree('get_selected');
    

    This will return, for example, ["selected_id1", "selected_id2", "selected_id3"]. If you want to get the selected nodes (not IDs), you can do this:

    var nodes = $('#tree').jstree('get_selected', true);
    

    The current docs contain more information.

提交回复
热议问题