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

前端 未结 14 2383
北恋
北恋 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

    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.

提交回复
热议问题