loader image
Skip to main content
If you continue browsing this website, you agree to our policies:
x
Completion requirements

In the DOM, all document parts are organized in a hierarchical tree-like structure consisting of parents and children. These individual parts are called Nodes. The Node interface is an abstract base class, so there is no such thing as a plain Node object. Look at some of the most used properties nodeType, parentNode, childNodes, firstChild, lastChild, previousSibling, nextSibling, and attributes.

Node

The DOM Node interface is an abstract base class upon which many other DOM API objects are based, thus letting those object types to be used similarly and often interchangeably. As an abstract class, there is no such thing as a plain Node object. All objects that implement Node functionality are based on one of its subclasses. Most notable are Document, Element, and DocumentFragment.

In addition, every kind of DOM node is represented by an interface based on Node. These include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are all based on), and DocumentType.

In some cases, a particular feature of the base Node interface may not apply to one of its child interfaces; in that case, the inheriting node may return null or throw an exception, depending on circumstances. For example, attempting to add children to a node type that cannot have children will throw an exception.

Diagram showing "EventTarget" pointing to "Node" with an arrow.


Source: Mozilla, https://developer.mozilla.org/en-US/docs/Web/API/Node
Creative Commons License This work is licensed under a Creative Commons Attribution 2.5 License.