Node in DOM Level 2 Core
The Node interface represents a single node in the document tree.
Inerhited by:
For official information please see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247.
Instance Properties
| name | type | description |
|---|---|---|
| nodeName | String | (read only) |
| nodeValue | String | |
| nodeType | Number | (read only) |
| parentNode | Node | (read only) |
| childNodes | NodeList | (read only) |
| firstChild | Node | (read only) |
| lastChild | Node | (read only) |
| previousSibling | Node | (read only) |
| nextSibling | Node | (read only) |
| attributes | NamedNodeMap | (read only) |
| ownerDocument | Document | (read only) |
| namespaceURI | String | (read only) |
| prefix | String | |
| localName | String | (read only) |
Instance Methods
| name | returns | description |
|---|---|---|
| insertBefore() | Node | |
| replaceChild() | Node | |
| removeChild() | Node | |
| appendChild() | Node | |
| cloneNode() | Node | Return a new copy of the node. |
| isSupported() | Boolean | |
| hasChildNodes() | Boolean | |
| normalize() | (none) | |
| hasAttributes() | Boolean |
Constants
| name | object | value | description |
|---|---|---|---|
| ELEMENT_NODE | Node | 1 | |
| ATTRIBUTE_NODE | Node | 2 | |
| TEXT_NODE | Node | 3 | |
| CDATA_SECTION_NODE | Node | 4 | |
| ENTITY_REFERENCE_NODE | Node | 5 | |
| ENTITY_NODE | Node | 6 | |
| PROCESSING_INSTRUCTION_NODE | Node | 7 | |
| COMMENT_NODE | Node | 8 | |
| DOCUMENT_NODE | Node | 9 | |
| DOCUMENT_TYPE_NODE | Node | 10 | |
| DOCUMENT_FRAGMENT_NODE | Node | 11 | |
| NOTATION_NODE | Node | 12 |
Description
The Node interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the Node interface expose methods for dealing with children, not all objects implementing the Node interface may have children. For example, Text nodes may not have children, and adding children to such nodes results in a DOMException being raised.
The attributes nodeName, nodeValue and attributes are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific nodeType (e.g., nodeValue for an Element or attributes for a Comment), this returns null. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.
Properties that are a Node
| name | object | description |
|---|---|---|
| parentNode | Node | (read only) |
| firstChild | Node | (read only) |
| lastChild | Node | (read only) |
| previousSibling | Node | (read only) |
| nextSibling | Node | (read only) |
| relatedNode | [events] MutationEvent | (read only) |
| ownerNode | [stylesheets] StyleSheet | (read only) |
Methods that return a Node
| name | of object | description |
|---|---|---|
| importNode() | Document | Imports a node from another document to this document. |
| insertBefore() | Node | |
| replaceChild() | Node | |
| removeChild() | Node | |
| appendChild() | Node | |
| cloneNode() | Node | Return a new copy of the node. |
| item() | NodeList | |
| getNamedItem() | NamedNodeMap | |
| setNamedItem() | NamedNodeMap | |
| removeNamedItem() | NamedNodeMap | |
| item() | NamedNodeMap | |
| getNamedItemNS() | NamedNodeMap | |
| setNamedItemNS() | NamedNodeMap | |
| removeNamedItemNS() | NamedNodeMap | |
| item() | HTMLCollection | |
| namedItem() | HTMLCollection | |
| item() | HTMLOptionsCollection | |
| namedItem() | HTMLOptionsCollection |
Arguments that are a Node
| name | in method | of object | description |
|---|---|---|---|
| importedNode | importNode() | Document | The node to import. |
| newChild | insertBefore() | Node | |
| refChild | insertBefore() | Node | |
| newChild | replaceChild() | Node | |
| oldChild | replaceChild() | Node | |
| oldChild | removeChild() | Node | |
| newChild | appendChild() | Node | |
| arg | setNamedItem() | NamedNodeMap | |
| arg | setNamedItemNS() | NamedNodeMap | |
| relatedNodeArg | initMutationEvent() | [events] MutationEvent |