我有一棵树,我从 zTree 中获取了样本,但我无法从这棵树中获取选定的值。虽然我已经对原始代码进行了更改,但在这里我发布了官方 Ztree Demo 的原始代码。任何帮助!
<SCRIPT type="text/javascript">
var setting = {
data: {
simpleData: {
enable: true
}
}
};
存储树节点的数组
var zNodes =[
{ id:1, pId:0, name:"pNode 1", open:true},
{ id:11, pId:1, name:"pNode 11"},
{ id:111, pId:11, name:"leaf node 111"},
{ id:12, pId:1, name:"pNode 12"},
{ id:121, pId:12, name:"leaf node 121"},
{ id:13, pId:1, name:"pNode 13 - no child", isParent:true},
{ id:2, pId:0, name:"pNode 2"},
{ id:21, pId:2, name:"pNode 21", open:true},
{ id:211, pId:21, name:"leaf node 211"},
{ id:22, pId:2, name:"pNode 22"},
{ id:221, pId:22, name:"leaf node 221"},
{ id:23, pId:2, name:"pNode 23"},
{ id:231, pId:23, name:"leaf node 231"},
{ id:3, pId:0, name:"pNode 3 - no child", isParent:true}
];
从该数组初始化树
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
</SCRIPT>
这里树显示在 id 为 treeDemo 的 Div 中。在这里,我想从这棵树中提醒警报框中的选定值。
<BODY>
<div class="content_wrap">
<div class="zTreeDemoBackground left">
<ul id="treeDemo" class="ztree"></ul>
</div>
</div>
</BODY>