Skip to content
SiteEmail

Node

Module: JavaScript DOM API

The basic document node.

#include <Node.idl>

Inherits from EventTarget

Inherited by Attr, CharacterData, Document, DocumentFragment, DocumentType, Element

Name
NoderemoveChild(Node oldChild)
remove a child node
NodeappendChild(Node newChild)
append a node as a child
voidappend((Node or DOMString)… newChildren)
append nodes and string objects as children, where the string objects are inserted as equivalent Text nodes
NodereplaceChild(Node newChild, Node oldChild)
replace oldChild with newChild
NodeinsertBefore(Node node, Node? referenceNode)
insert a node before the reference node, as a child of the current node
NodecloneNode(optional boolean deep =false)
booleanisEqualNode(Node? otherNode)
booleanisSameNode(Node? otherNode)
booleanhasChildNodes()
booleancontains(Node? other)
DOMStringlookupPrefix(DOMString? namespace)
booleanisDefaultNamespace(DOMString? namespace)
voidnormalize()
unsigned shortcompareDocumentPosition(Node other)
NodegetRootNode(optional GetRootNodeOptions options)
DOMStringlookupNamespaceURI(DOMString? prefix)
Name
const unsigned shortELEMENT_NODE
const unsigned shortATTRIBUTE_NODE
const unsigned shortTEXT_NODE
const unsigned shortCDATA_SECTION_NODE
const unsigned shortENTITY_REFERENCE_NODE
const unsigned shortENTITY_NODE
const unsigned shortPROCESSING_INSTRUCTION_NODE
const unsigned shortCOMMENT_NODE
const unsigned shortDOCUMENT_NODE
const unsigned shortDOCUMENT_TYPE_NODE
const unsigned shortDOCUMENT_FRAGMENT_NODE
const unsigned shortNOTATION_NODE
const unsigned shortDOCUMENT_POSITION_DISCONNECTED
const unsigned shortDOCUMENT_POSITION_PRECEDING
const unsigned shortDOCUMENT_POSITION_FOLLOWING
const unsigned shortDOCUMENT_POSITION_CONTAINS
const unsigned shortDOCUMENT_POSITION_CONTAINED_BY
const unsigned shortDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
readonly attribute DOMStringnodeName
attribute DOMStringnodeValue
attribute DOMStringtextContent
readonly attribute unsigned shortnodeType
type of the node
readonly attribute NodeparentNode
parent of the node
readonly attribute ElementparentElement
parent element of the node. If parent is not an Element, returns null.
readonly attribute NodeListchildNodes
list of the children of this node
readonly attribute NodefirstChild
the node’s first child in the tree, or null if the node is childless
readonly attribute NodelastChild
last child of the node, or null if there are no child elements
readonly attribute NodepreviousSibling
the node immediately preceding the specified one in its parent’s children, or null if the specified node is the first in that list
readonly attribute NodenextSibling
the node immediately following the specified one in its parent’s children, or null if the specified node is the last node in that list
readonly attribute DocumentownerDocument
The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.
readonly attribute USVStringbaseURI
readonly attribute booleanisConnected
attribute EventSetterslotchange

Public Functions inherited from EventTarget

Name
voidaddEventListener(DOMInternedString type, EventListener listener, optional AddEventListenerOptions options)
voidremoveEventListener(DOMInternedString type, EventListener listener, optional RemoveEventListenerOptions options)
booleandispatchEvent(Event event)
Node removeChild(
Node oldChild
)

remove a child node

Parameters:

  • oldChild the child node to be removed

Return: the removed child node

Node appendChild(
Node newChild
)

append a node as a child

Parameters:

  • newChild the node to append

Return: the appended child node

void append(
(Node or DOMString)... newChildren
)

append nodes and string objects as children, where the string objects are inserted as equivalent Text nodes

Parameters:

  • newChildren the nodes or strings to append
Node replaceChild(
Node newChild,
Node oldChild
)

replace oldChild with newChild

Return: the replaced child node

Node insertBefore(
Node node,
Node? referenceNode
)

insert a node before the reference node, as a child of the current node

Parameters:

  • node the new node to be inserted
  • referenceNode the reference node (if null, node will be inserted at the end of the child nodes list)

Return: the inserted node

Node cloneNode(
optional boolean deep =false
)

Return: a clone of the node

boolean isEqualNode(
Node? otherNode
)
boolean isSameNode(
Node? otherNode
)
boolean hasChildNodes()
boolean contains(
Node? other
)
DOMString lookupPrefix(
DOMString? namespace
)
boolean isDefaultNamespace(
DOMString? namespace
)
void normalize()
unsigned short compareDocumentPosition(
Node other
)
Node getRootNode(
optional GetRootNodeOptions options
)
DOMString lookupNamespaceURI(
DOMString? prefix
)
const unsigned short ELEMENT_NODE = 1;
const unsigned short ATTRIBUTE_NODE = 2;
const unsigned short TEXT_NODE = 3;
const unsigned short CDATA_SECTION_NODE = 4;
const unsigned short ENTITY_REFERENCE_NODE = 5;
const unsigned short ENTITY_NODE = 6;
const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
const unsigned short COMMENT_NODE = 8;
const unsigned short DOCUMENT_NODE = 9;
const unsigned short DOCUMENT_TYPE_NODE = 10;
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
const unsigned short NOTATION_NODE = 12;
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;

variable DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC

Section titled “variable DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC”
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
readonly attribute DOMString nodeName;
attribute DOMString nodeValue;
attribute DOMString textContent;
readonly attribute unsigned short nodeType;

type of the node

readonly attribute Node parentNode;

parent of the node

readonly attribute Element parentElement;

parent element of the node. If parent is not an Element, returns null.

readonly attribute NodeList childNodes;

list of the children of this node

readonly attribute Node firstChild;

the node’s first child in the tree, or null if the node is childless

readonly attribute Node lastChild;

last child of the node, or null if there are no child elements

readonly attribute Node previousSibling;

the node immediately preceding the specified one in its parent’s children, or null if the specified node is the first in that list

readonly attribute Node nextSibling;

the node immediately following the specified one in its parent’s children, or null if the specified node is the last node in that list

readonly attribute Document ownerDocument;

The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.

readonly attribute USVString baseURI;
readonly attribute boolean isConnected;
attribute EventSetter slotchange;