ztree 簡單應用一

1:代碼部分html

<!-- lang: html -->
<div>
    <ul id="" class=""></ul>
</div>
<!-- lang: js -->
<script> 
var nodes2 = [
    {id: 1, pId: 0, name: "parent1"},
    {id: 11, pId: 1, name: "children1"},
    {id: 12, pId: 1, name: "children2"},
    {id: 2, pId: 0, name: "parent2"},
    {id: 21, pId: 2, name: "children1"},
    {id: 22, pId: 2, name: "children2"},
    {id: 3, pId: 0, name: "parent3"},
    {id: 31, pId: 3, name: "children1"},
    {id: 32, pId: 3, name: "children2"},
];   
var setting = {
    data: {
        simpleData: {
            enable: true
        }
    }
};
$(document).ready(function () {
    $.fn.zTree.init($("#treeDemo"), setting, nodes2);
})</script>

2:實驗結果node

在此輸入圖片描述

3:小結code

相關文章
相關標籤/搜索