`
okwxj
  • 浏览: 2619 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表

关于DOM遍历

关于DOM遍历的补充: 如前所述,IE6 DOM中childNodes.length每次都是要遍历所有节点统计个数得出的。而childNodes[i]的访问,也要遍历直到第i个元素。所以在子节点数量巨大的情况下(超过1000),不宜使用for循环来遍历childNodes,否则会死得很惨。而应使用这样的遍历方法: var node = elem.firstChild; while (node != null) { ... node = node.nextSibling; } 另一个方式是使用IE自己的DHTML集合属性elem.children,但是它与childNode ...
if(typeof(HTMLElement)!="undefined" && !window.opera) { HTMLElement.prototype.__defineGetter__("outerHTML",function() { var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) if(a[i].specified) ...
Global site tag (gtag.js) - Google Analytics