if (node){
var nodes = [{
"id":13,
"text":"Raspberry"
},{
"id":14,
"text":"Cantaloupe"
}]
$('#tt').tree('append', {
parent:node.target,
data:nodes
})
}
<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>
<button id="add">添加</button><div id="box"></div>
<script>
$(function(){
$("#add").on("click",function(){
$("#box").append("<div><span>"+($("#box div").size()+1)+"</span><button>删除</button></div>")
})
$("#box").on("click","div button",function(){
$(this).parent().remove()
$("#box div span").each(function(i,e){
$(e).text(i+1)
})
})
})
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)