Node Interface

Instance properties

In addition to the properties below, Node inherits properties from its parent, EventTarget.

Node.baseURI Read only

Returns a string representing the base URL of the document containing the Node.

Node.childNodes Read only

Returns a live NodeList containing all the children of this node (including elements, text and comments). NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.

Node.firstChild Read only

Returns a Node representing the first direct child node of the node, or null if the node has no child.

Node.isConnected Read only

A boolean indicating whether or not the Node is connected (directly or indirectly) to the context object, e.g. the Document object in the case of the normal DOM, or the ShadowRoot in the case of a shadow DOM.

Node.lastChild Read only

Returns a Node representing the last direct child node of the node, or null if the node has no child.

Node.nextSibling Read only

Returns a Node representing the next node in the tree, or null if there isn't such node.

Node.nodeName Read only

Returns a string containing the name of the Node. The structure of the name will differ with the node type. E.g. An HTMLElement will contain the name of the corresponding tag, like 'audio' for an HTMLAudioElement, a Text node will have the '#text' string, or a Document node will have the '#document' string.

Node.nodeType Read only

Returns an unsigned short representing the type of the node. Possible values are:

Name Value
ELEMENT_NODE 1
ATTRIBUTE_NODE 2
TEXT_NODE 3
CDATA_SECTION_NODE 4
PROCESSING_INSTRUCTION_NODE 7
COMMENT_NODE 8
DOCUMENT_NODE 9
DOCUMENT_TYPE_NODE 10
DOCUMENT_FRAGMENT_NODE 11
Node.nodeValue

Returns / Sets the value of the current node.

Node.ownerDocument Read only

Returns the Document that this node belongs to. If the node is itself a document, returns null.

Node.parentNode Read only

Returns a Node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.

Node.parentElement Read only

Returns an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.

Node.previousSibling Read only

Returns a Node representing the previous node in the tree, or null if there isn't such node.

Node.textContent

Returns / Sets the textual content of an element and all its descendants.