关于jquery tree 树形菜单动态添加子节点的问题

发布网友 发布时间:2022-04-22 14:05

我来回答

2个回答

热心网友 时间:2022-04-22 17:55

<script type="text/javascript">
function getChildren(){
var node = $('#tt1').tree('getSelected'); //tt1是你的树的id
if (node){
alert(“有子节点");
} else {
alert("无子节点");
}
}
</script>

<ul id="tt1" class="easyui-tree" animate="true" dnd="false">
<li>
<span>Folder</span>
<ul>
<li state="closed">
<span>Sub Folder 1</span>
<ul>
<li>
<span><a href="">File 11</a></span>
</li>
<li>
<span>File 12</span>
</li>
<li>
<span>File 13</span>
</li>
</ul>
</li>
<li>
<span>File 2</span>
</li>
<li>
<span>File 3</span>
</li>
<li>File 4</li>
<li>File 5</li>
</ul>
</li>
<li>
<span>File21</span>
</li>
</ul>
<a href="#" onclick="getChildren1()">getChildren1</a>

热心网友 时间:2022-04-22 19:13

$().ready(function(){
$('#TreeMenu').tree( {
checkbox : true,
cascadeCheck:false,
url : "fun!getTree.action?id=-1",
onBeforeExpand:function(node)
{
$.getJSON("fun!getTree.action?id="+node.id,function(nodes){
$('#TreeMenu').tree('append', {
parent:node.target,
data:nodes
});
});
}
});
});

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com