[英]jsTree : How to get IDs of selected nodes to root node in jsTree?
[英]JsTree how to get IDs of group node
jsTree的API提供了節點間識別和遍歷的功能。 這是一個小腳本,您可以使用它來識別子節點、父節點(直接級別)和兄弟節點(直級別)。
$('#jstree').bind('select_node.jstree', function (e, data) {
var tree = $('#jstree').jstree(true),
parentNode = tree.get_node(data.node.parent),
aChildren = data.node.children,
aSiblings = [];
parentNode.children.forEach(function(c){
if(c !== data.node.id) aSiblings.push(c);
});
console.log("1.)" + JSON.stringify(aChildren));
console.log("2.)" + JSON.stringify(parentNode.id));
console.log("3.)" + JSON.stringify(aSiblings));
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.