循环删除dom节点的字节点和已经注册的dijit组件
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 //递归删除parent下的dom节点和dijit组件 2 function deleChild(parent){ 3 var childs =parent.childNodes; 4 for(var i=childs.length;i--;i>0){ 5 if( childs[i].hasChildNodes() ){ 6 deleChild(childs[i]); 7 } 8 9 if(childs[i] && childs[i].id && dijit.byId(childs[i].id)){ 10 dijit.byId(childs[i].id).destroy(); 11 12 }else{ 13 if(childs[i]){ 14 parent.removeChild(childs[i]); 15 } 16 } 17 18 } 19 }