Use of Firefox's elementtraversal Interface

Source: Internet
Author: User

Firstelementchild
This attribute of element 1 must be referenced by the first subnode of the nodetype 1 element as an element object. If the accessed element attribute does not have any subnodes, or if none of these subnodes are element nodes, null must be returned for this attribute.
Lastelementchild
To access this attribute of element 1, the last child node reference of the nodetype 1 element must be returned as an element object. If the accessed element attribute does not have any subnodes, or if none of these subnodes are element nodes, null must be returned for this attribute.
Previuselementsibling
To access this attribute of element 1, the reference of the node that belongs to the nodetype 1 element prior to the element in the file order must be returned as an element object. If the accessed element property does not have any same-level nodes before it, or if all these same-level nodes are not element nodes, the property must return null.
Nextelementsibling
This attribute for accessing element 1 must be followed by the reference of the node of the nodetype 1 element in the file order and returned as an element object. If the accessed element property does not have any nodes of the same level after it, or if all these nodes are not element nodes, the property must return null.
Childelementcount
This attribute of element 1 must be returned and belongs to nodetype 1. the current number of element child nodes. when accessing this attribute, the execution may store the number or calculate the number. However, this number must always represent the number of child element nodes when accessing this attribute. Only direct subnodes should be included. If one of the accessed attribute element subnodes has an element subnode, this level is not counted. If the element accessed by the attribute has no subnodes, or all these subnodes are not element nodes, the attribute must return 0.

CopyCode The Code is as follows: function spacechildren (EL ){
// Calculate the number of element nodes
VaR elcount = El. childelementcount;

VaR eachwidth = Window. innerwidth/(elcount + 1 );

// Obtain the first child element
VaR childel = El. firstelementchild;

// Set the initial position
VaR nextpos = eachwidth/2;

// Loop sub-elements one by one
While (childel ){
// Add child elements
Childel. style. setproperty ('position', 'absolute ','');
Childel. style. setproperty ('left', nextpos + 'px ','');
Childel. style. setproperty ('width', eachwidth + 'px ','');

// Increase by width
Nextpos + = eachwidth;

// Then navigate to the next child element
Childel = childel. nextelementsibling;
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.