Node object (Object/DOM)

A node is the primary component from which documents are built (in the context of a DOM hierarchy).

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
JavaScript syntax:-myNode = myMutationEvent.relatedNode
Object properties:firstChild, lastChild, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, previousSibling
Class constants:ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Object methods:appendChild(), cloneNode(), hasChildNodes(), insertBefore(), removeChild(), replaceChild()
Collections:attributes[], childNodes[]

Here is a list of the available node types:

ConstantTypeDescription
undefinednullA member of the attributes collection
ELEMENT_NODE1HTML element object node
ATTRIBUTE_NODE2HTML tag attribute object
TEXT_NODE3Text object node
CDATA_SECTION_NODE4CDATA section
ENTITY_REFERENCE_NODE5Entity reference
ENTITY_NODE6Entity node
PROCESSING_INSTRUCTION_NODE7Processing instruction node
COMMENT_NODE8Comment node
DOCUMENT_NODE9Document object
DOCUMENT_TYPE_NODE10Doctype object
DOCUMENT_FRAGMENT_NODE11Document fragment node
NOTATION_NODE12Notation node

The DOM level 2 specification adds the following methods:

It also adds the following properties:

At DOM level 3, the interface to the Node object is expected to evolve further to allow nodes to be compared and to be able to extract a serialized version of a DOM tree branch into a string primitive. This functionality is still under review as this is being written. The following additional properties are expected to be supported:

DOM level 3 is expected to add the following methods to the Node object:

If the implementation supports the DOM level 2 event model (this is the case with Netscape 6.0), then the Node object should also support the methods and properties defined by the EventTarget object.

See also:Attribute.nodeType, Document object, DocumentFragment object, Element object, EventTarget object, MutationEvent.initMutationEvent(), MutationEvent.relatedNode, NamedNodeMap object, Node.firstChild, Node.insertBefore(), Node.lastChild, Node.nextSibling, Node.parentNode, Node.previousSibling

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
firstChild1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
lastChild1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
nextSibling1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
nodeName1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
nodeType1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
nodeValue1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
ownerDocument1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
parentNode1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
previousSibling1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
appendChild()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
cloneNode()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
hasChildNodes()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
insertBefore()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
removeChild()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-
replaceChild()1.5 1.55.0 5.06.0 6.05.0 5.0 n/a n/a n/a1 1 n/a n/a-