Elements
All of the elements in the document hierarchy have the following useful
attribute:
-
element.childNodes - a read-only array containing the
children of element.
The size of this array is element.childNodes.length.
Although the array is read-only, it can be manipulated using methods
described below.
All of the elements in the document hierarchy have the following useful
methods:
-
getElementsByTagName(tagName) - returns an array of HTML
elements whose tag name is tagName.
The entire descendent hierarchy is searched.
-
appendChild(element) - appends element at the
end of the childNodes array.
-
removeChild(child) - removes child from the
childNodes array.
-
replaceChild(newChild, oldChild) - replaces
oldChild in the childNodes array by newChild.
Nodes are not created by invoking constructors.
They are created by invoking the Document methods createTextNode() and
createElement().