创建元素

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);

相关文章:

  • 2022-01-12
  • 2021-06-06
  • 2021-04-14
  • 2021-07-31
猜你喜欢
  • 2021-05-17
  • 2022-12-23
  • 2021-05-22
  • 2022-01-18
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
相关资源
相似解决方案