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

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

    to get all selected ids use the below code

    var selectedData = [];
    var selectedIndexes;
     selectedIndexes = $("#jstree").jstree("get_selected", true);
    jQuery.each(selectedIndexes, function (index, value) {
         selectedData.push(selectedIndexes[index].id);
     });
    

    now you have all the selected id's in the "selectedData" variable

提交回复
热议问题