如何在jsTree中获取所选节点的id
function createNewNode() {
  alert('test');
  var tree = $.tree.reference("#basic_html");
  selectedNodeId = xxxxxxxxx; //insert instruction to get id here
  tree.create({ data : "New Node Name" }, selectedNodeId);
}发布于 2011-07-13 11:10:57
由于无法使用harpo的解决方案,并且不愿意使用Olivier的解决方案,因为它使用内部jsTree函数,所以我想出了一种不同的方法。
$('#tree').jstree('get_selected').attr('id')就这么简单。get_selected函数返回选定列表项的数组。如果对该数组执行.attr,jQuery将查看列表中第一项。如果您需要多个选择的ID,则将其视为数组。
https://stackoverflow.com/questions/2585502
复制相似问题