/** * 递归查找目标节点 */ function findTarget(obj,targetId,targetChildren){ if(obj.id==targetId){ obj.children=targetChildren; return true; }else{ if(obj.children!=null){ for(var i=0; i<obj.children.length; i++){ var flag=findTarget(obj.children[i],targetId,targetChildren); if(flag==true){ return true; } } } } return false; }