首页 > 代码库 > jquery和zTree 树结构的测试demo

jquery和zTree 树结构的测试demo

js代码:
 
<link type="text/css" rel="stylesheet" href=http://www.mamicode.com/plugin/zTree/css/zTreeStyle/zTreeStyle.css" />>
<!-- 注意 jquery-1.9.1.min.js必须放在jquery.ztree.all-3.5.js之前引入 -->
<script type="text/javascript" language="javascript"> var setting = {        async: {            enable: true,            type:'post',            url:"treedata.json"        },        data: {            simpleData: {   //简单的数据源
            enable: true,            idKey: "id",  //id和pid,树的目录级别              pIdKey: "pId",            rootPId: 0   //根节点            }        },        check: {  //checkbox复选框            enable: true,   //显示or不显示            chkboxType: {"Y":"", "N":""}        },        callback: {            onAsyncSuccess: zTreeOnAsyncSuccess  /**回调函数的设置,提交成功的回调函数**/        }    };   function zTreeOnAsyncSuccess(){       alert("success");   }    $(document).ready(function(){//初始化ztree对象        $.fn.zTree.init($("#cityTree"), setting);       $('#city').comboboxTree({            url:'comboboxTree.json'        });    });</script>


html代码:

 

<div class="row">            <div class="col-2">                <p class="summer-grid-title">出生地</p>            </div>            <div class="col-2">                <ul id="cityTree" class="ztree"></ul>            </div>            <div class="col-4">                <input type="text" id="city" name="city" class="summer-input" data-validate="required:true;">            </div></div>


 

jquery和zTree 树结构的测试demo