使用jquery的treeview插件建立树状图

http://docs.jquery.com/Plugins/Treeview到这里下载压缩包

下面是个例子

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../catalog/jquery.treeview.css" />
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.cookie.js" type="text/javascript"></script>
<script src="jquery.treeview.js" type="text/javascript"></script>
</head>
<body>
	<script type="text/javascript">
		
		$(document).ready(function() {			
			$("#example").treeview({//需要最外层ul的id
				collapsed: true,//默认折叠
				animated: "medium",//动画效果速度
				control:"#sidetreecontrol",
				persist: "location"
			});
		});
	</script>
	<div id="treeviewDiv">
		<ul id="example" class="filetree">
			<li><span class="folder">Folder 1</span>
				<ul>
					<li><a href="http://www.sina.com.cn" class="file" target="baseframe">Item 1.1</a></li>
				</ul>
			</li>
			<li><span class="folder">Folder 2</span>
				<ul>
					<li><span class="folder">Subfolder 2.1</span>
						<ul>
							<li><span class="file">File 2.1.1</span></li>
							<li><span class="file">File 2.1.2</span></li>
						</ul>
					</li>
					<li><span class="file">File 2.2</span></li>
				</ul>
			</li>
			<li class="closed"><span class="folder">Folder 3 (closed
					at start)</span>
				<ul>
					<li><span class="file">File 3.1</span></li>
				</ul>
			</li>
			<li><span class="file">File 4</span></li>
		</ul>
	</div>
</body>
</html>

我理解的一个一个root级的结点代码应该是

<ul>此root结点的外层ul
     <li>	一个li表示一行内容
        <span></span>或<a></a>span或a标签可以设置显示标题和图片,a标签的话自定义点击事件比较轻松
        <ul> ul标签用于想内部插入非root子节点或root子结点
        </ul>
     </li>
</ul>


而非root级的就是一个li就行了

<li>
   <a><span></span></a>
</li>


只要html代码复合ul li规范执行一行命令即可

$("#example").treeview({//需要最外层ul的id
	collapsed: true,//默认折叠
	animated: "medium",//动画效果速度
	control:"#sidetreecontrol",
	persist: "location"
});



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值