Java Reference
In-Depth Information
sports.children // this will only contain paragraph
<< HTMLCollection [ <p>, <p>, <p> ]
<< 3
The firstChild property returns the first child of a node:
<< #text "
And the lastChild property returns the last child of a node:
<< #text "
Be careful when using these properties―the first or last child node can often be a text node,
even if it's just an empty string generated by some whitespace.
For example, you might expect the first child node of the sports element to be the swim
element and the last child to be the run element, but it is in fact a text node, generated by
the whitespace characters in between the <section> and <p> tags:
The parentNode property returns the parent node of an element. The following code re-
turns the sports node because it is the parent of the bike node:
<< <section id="sports">
The nextSibling property returns the next adjacent node (that is, the same parent). It
will return null if the node is the last child node of that parent:
<< #text "
Search WWH ::

Custom Search