element traversal

来源:互联网 发布:京东关键词排名优化 编辑:程序博客网 时间:2024/06/16 21:38

childElementCount:  returns the number of child elements (excludes text nodes and comments);

firstElementChild: points to the first child that is an element.Element-only version of firstChild

lastElementChild: points to the last child that is an element.Element-only version of lastChild

previousElementSibling: points to the previous sibling that is an element . Element-only version of previousSibling

nextElementSibling: points to the next sibling that is an element . Element-only version of nextSibling


var i,len child=element.firstElementChild;

while(child!=element.lastElementChild){

//.....

child=child.nextElementSibling;

}