码家

Web Platform, Cloud and Mobile Application Development

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 var json = [{tcName:"11", children:[{tcName:"22", children:[{tcName:"33"}]}, {tcName:"44", children:[{tcName:"55"}, {tcName:"55"}]}]}]; 
                readTree(json[0], $("#load")); 

        function readTree(node, ul) { 
            var li = $(["<li>" + 
                    "<a href=\"", "/ccs", "/trainCenter/index.do?get=\"", 12, "\">", node.tcName, "</a>" + 
                    "</li>"].join("")).appendTo(ul); 
            var children = node.children; 
            if (children && children.length) { 
                ul = $("<ul></ul>").appendTo(li); 
                for (var i = 0; i < children.length; i++) { 
                    readTree(children[i], ul); 
                } 
            } 
        } 

页面 
<ul id="load"></ul> 


显示结果: 
     。11 
         。22 
             33 
         。44 
             55 
             55 

posted on 2013-10-02 11:17  海山  阅读(1920)  评论(0编辑  收藏  举报