jquery easyui判断树形是否有子节点
1个回答
展开全部
<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="http://www.baidu.com">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>
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="http://www.baidu.com">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>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询