<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="js/jquery.ztree.core-3.5.js"></script> <script type="text/javascript" src="js/jquery.ztree.excheck-3.5.js"></script> <script type="text/javascript" src="js/jquery.ztree.exedit-3.5.js"></script> <link rel="stylesheet" href="css/zTreeStyle/zTreeStyle.css" type="text/css">引入的js和css
jquery.ztree.core-3.5.js:zTree核心包
jquery.ztree.excheck-3.5.js:复选框功能包
jquery.ztree.exedit-3.5.js:编辑功能包
zTree核心包是必须引入的
var zTreeObj; var setting = {}; var zNodes = [{ name: "test1", open: true, children: [{ name: "test1_1" }, { name: "test1_2" }] }, { name: "test2", open: true, children: [{ name: "test2_1" }, { name: "test2_2" }] }]; $(document).ready(function() { zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes); });js
<div id="treeDemo" class="ztree"></div> 或者 <div> <ul id="treeDemo" class="ztree"></ul> </div>html容器声明
效果图:
标签:jquery,test1,test2,name,树形,js,ztree From: https://www.cnblogs.com/rdchen/p/17269376.html