$(function(){
   var data=[{ ...  }];  //json树形字符串 
   $("#dataInput").click(function(){
      var options="";
      var count=8;
      if(data.length==1){  
         options = displayMenu(data[0], options,count);   
      }   
      $("#ss").html(options); 
   });
});
 
function displayMenu(model, options,count) {
   count=count+8;
   for(var j=0;j<model.children.length;j++){
      var childs = model.children;
      options = options + "<li>"+getEmptyString(count)+childs[j].displayName+"</li>";
      if (childs.length > 0) {
         options = displayMenu(childs[j], options,count);
      }
   }
   return options;
};

function getEmptyString(count){
   var text = '';
   for(var i=0;i<count;i++){
      text=text+'&nbsp;';
   }
   return text;
}

相关文章:

  • 2021-08-31
  • 2021-12-16
  • 2021-03-30
  • 2021-09-03
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-11
  • 2022-03-03
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案