我需要通過屬性名稱在jstree中選擇一個節點。然後選擇該節點後,我需要得到它的ID。 基本上我想得到一個節點的id給定它的名字。jstree:通過名稱屬性而不是id來選擇jstree中的一個節點
我嘗試下面的代碼:
$("#tree1").bind("loaded.jstree", function (e, data) {
var isa_name = "ISA16469";
//$("#tree1").jstree("select_node", "#01"); //this code works but it selects by id, I want to select by attribute name
$("#tree1").jstree("select_node", $("li[name='" + isa_name + "']")); //doesn't work
var test = $('#tree1').jstree('get_selected').attr('id'); //get id of selected node
alert(test)
})
你的幫助是最歡迎的。非常感謝