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

前端 未结 14 2323
北恋
北恋 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:27

    Just use

    var nodeId = $('#FaqTreeView').jstree().get_selected("id")[0].id;
    

    where #FaqTreeView is the id of your div that contains the jstree.

    0 讨论(0)
  • 2020-12-29 23:27

    These are all old answers for old versions. As of version 3.3.3 this will work to get all attributes of the selected node.

    $('#jstree').jstree().get_selected(true)[0]
    

    If you then want the id then add .id at the end. You can look at all the other attributes in web developer tools if you copy the above code.

    0 讨论(0)
提交回复
热议问题