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