我目前正在使用dynaTree jQuery插件来渲染树.
<div id="tree" style="height:100px;">
<ul class="expanded">
<li class="expanded" id="shtml_1" >
<a class="ajaxify" href="jsTree.html" >Root node 1</a>
<ul>
<li id="shtml_2">
<a href="#">Child node 1</a>
<ul>
<li id="a"><a href="#">Child node 1-1</a></li>
<li id="x"><a href="b">Child node 1-2</a></li>
</ul>
</li>
<li id="c"><a href="#">Child node 2</a></li>
</ul>
</li>
<li id="shtml_4">
<a href="#">Root node 2</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
Javascript -
$('.ajaxify').ajaxify({
target: '#container'
});
$(function(){
$("#tree").dynatree({
title: "Sample Theming",
// Image folder used for data.icon attribute.
imagePath: "skin-custom/",
onSelect: function(node) {
alert ("You selected " + …Run Code Online (Sandbox Code Playgroud)