Node

Node is an interface from which a number of DOM API object types inherit; it allows these various types to be treated similarly, for example inheriting the same set of methods, or being tested in the same way.

These interfaces may return null in particular cases where the methods and properties are not relevant. They may throw an exception - for example when adding children to a node type for which no children can exist.

Properties

Returns a DOMString representing the base URL. The concept of base URL changes from one language to another; in HTML, it corresponds to the protocol, the domain name and the directory structure, that is all until the last '/'.

Returns 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.

Returns a DOMString 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.

Obsolete properties

Returns a DOMString representing the local part of the qualified name of an element.

Note: In Firefox 3.5 and earlier, the property upper-cases the local name for HTML elements (but not XHTML elements). In later versions, this does not happen, so the property is in lower case for both HTML and XHTML.

Methods

Adds the specified childNode argument as the last child to the current node.
If the argument referenced an existing node on the DOM tree, the node will be detached from its current position and attached at the new position.

The methods insertBefore(), replaceChild(), removeChild(), and appendChild() returns one more kind of error (NOT_SUPPORTED_ERR) if called on a Document.
The normalize() method has been modified so that Text node can also be normalized if the proper DOMConfiguration flag is set.
Added the following methods: compareDocumentPosition(), isSameNode(), lookupPrefix(), isDefaultNamespace(), lookupNamespaceURI(), isEqualNode(), getFeature(), setUserData(), and getUserData().
Added the following properties: baseURI and textContent.

The ownerDocument property was slightly modified so that DocumentFragment also returns null.
Added the following properties: namespaceURI, prefix, and localName.
Added the following methods: normalize(), isSupported() and hasAttributes().

1. WebKit and old versions of Blink incorrectly do not make Node inherit from EventTarget.

2. This API was moved to the Element and Attr APIs according to the DOM4 standard.

3. The ownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node. DOCUMENT_TYPE_NODE or 10) is no longer null. Instead, the ownerDocument is the document on which document.implementation.createDocumentType() was called.

Notes The ownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node. DOCUMENT_TYPE_NODE or 10) is no longer null. Instead, the ownerDocument is the document on which document.implementation.createDocumentType() was called.

Notes The ownerDocument of doctype nodes (that is, nodes for which Node.nodeType is Node. DOCUMENT_TYPE_NODE or 10) is no longer null. Instead, the ownerDocument is the document on which document.implementation.createDocumentType() was called.