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

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

    In some cases and/or jstree versions this solution doesn't work.

    $('#tree').jstree('get_selected').attr('id');
    

    Instead of defined "id" I get nothing. What did the trick for me is:

    $("#tree").jstree("get_selected").toString();
    

提交回复
热议问题