Object: Node
Availability |
|
Extended by |
Attr, CharacterData, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction |
The Node object represents a unique node within the DOM tree. It is the primary data type for the DOM.
While Node exposes methods for dealing with children, not all objects inheriting from Node may have children. For example, Text nodes do not permit children; trying to add children to such nodes results in a DOMException being raised.
The Node.nodeName, Node.nodeValue, and Node.nodeType properties enable you to acquire node information without casting down to the specific child object. In cases where there is no obvious mapping of these properties for a specific nodeType (for example, the Node.nodeValue for an Element, or attributes for a Comment), they return null.
The specialized objects may contain additional and more convenient mechanisms to get and set the relevant information.
Node properties
|
Property name |
Type |
Description |
Status |
Support level |
Availability |
|---|---|---|---|---|---|
|
Returns a NamedNodeMap object that contains the attributes of the given element node, or null, if the node is not an element. |
read only |
DOM 2 Core |
4.6 or later |
||
|
Returns a NodeList object that contains all the child elements of the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
Returns the first child of the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
Returns the last child of the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
DOMString |
Returns the local part of the qualified name for the given node. |
read only |
DOM 2 Core |
4.6 or later |
|
|
DOMString |
Returns the namespace URI for the given node, or null if it is not specified. |
read only |
DOM 2 Core |
4.6 or later |
|
|
Returns the node immediately following the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
DOMString |
Returns the name of the given node. |
read only |
DOM 2 Core |
4.6 or later |
|
|
unsigned short |
Returns a code representing the type of the given node. |
read only |
DOM 2 Core |
4.6 or later |
|
|
DOMString |
Specifies the value of the given node. |
writable |
DOM 2 Core |
4.6 or later |
|
|
Returns the Document object associated with the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
Returns the parent of the given node. |
read only |
DOM 2 Core |
4.6 or later |
||
|
DOMString |
Specifies the prefix, extracted from the qualified name of the given node, or null if it is unspecified. |
writable |
DOM 2 Core |
4.6 or later |
|
|
Returns the node immediately preceding the current node. |
read only |
DOM 2 Core |
4.6 or later |
Node methods
|
Method name |
Description |
Support level |
Availability |
|---|---|---|---|
|
Adds an EventListener object to a set of event listeners for the given node. |
DOM 2 Events |
4.6 or later |
|
|
Adds a node to the end of the array of child nodes for the given node. |
DOM 2 Core |
4.6 or later |
|
|
Returns a duplicate of the given node. The duplicate node has no parent. |
DOM 2 Core |
4.6 or later |
|
|
Dispatches an Event object. |
DOM 2 Events |
4.6 or later |
|
|
Returns whether the given node has any attributes. |
DOM 2 Core |
4.6 or later |
|
|
Returns whether the given node has any children. |
DOM 2 Core |
4.6 or later |
|
|
Inserts a new node before the given node. |
DOM 2 Core |
4.6 or later |
|
|
Tests whether the given node supports a specific feature. |
DOM 2 Core |
4.6 or later |
|
|
Merges text nodes adjacent to the given element node to create a normalized DOM. |
DOM 2 Core |
4.6 or later |
|
|
Removes the specified child from the given element node and returns it. |
DOM 2 Core |
4.6 or later |
|
|
Removes an event listener from an EventTarget. |
DOM 2 Events |
4.6 or later |
|
|
Removes the specified child from the given and replaces it with another node, then returns the removed node. |
DOM 2 Core |
4.6 or later |