Node object

Node object

Represents non-element DOM nodes: text or comment.

Properties

parent
r – Element, parent element of the node or null if this node is not connected to any element. Read-only.
nodeIndex
r – Integer, index of the node in parent nodes collection.
nextNode
r – Element or Node, next sibling node of the node or null if this is the last element in parent collection.
priorNode
rElement or Node, previous sibling node of the node or null if this is the first node in parent collection.
text
rwString, text of the node. Read-write property.
isElement
rtrue if this node is an element, false – otherwise.
isText
rtrue if the node is a text node.
isComment
rtrue if the node is a comment node.

Methods

createText
(text: string) : Node

Static constructor of text DOM nodes.

createComment
(text: string) : Node

Static constructor of comment DOM nodes.

createElement
(tagname:symbol | string [, attributes: object] [, text:string]) : Element

Static constructor of Element [node]. Equivalent of new Element(...).

toString
() : string

Returns string – text representation of the node.

clone
() :Node

Returns new copy of the node. New node is disconnected from the DOM.

insertNodeBefore
( node: Node)

Inserts the node in the DOM tree before this element.

insertNodeAfter
( node: Node)

Inserts the node in the DOM tree after this element.

detach
( ) : Node

Removes this node from its parent’s nodes collection. After the call of this method this.parent will become null.

remove
( ) : Element

Removes this node from its parent’s nodes collection. After the call of this method this.parent will become null.