DOM操作应用

创建元素

document.createElement("li");

添加节点

oUl.appendChild(oLi);

在某个元素之前插入一个节点

oUl.insertBefore(oLi,oUl.firstChild);

删除节点

aA[i].onclick = function(){ 

   Ul.removeChild(this.parentNode);

}

//文档碎片

作用:类似于一个袋子,一次性装箱

好处:提高性能,但在高浏览器中性能受影响,适用于ie6,7

var oFrag = document.createDocumentFragment();  

for(var i=0; i<10000; i++){   

  var oLi = document.createElement("li");   

  oFrag.appendChild(oLi);    

}  

oUl.appendChild(oFrag);

原文地址:https://www.cnblogs.com/huaci/p/3817155.html