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
r - Element or Node, previous sibling node of the node or null if this is the first node in parent collection.
text
rw - String, text of the node. Read-write property.
isElement
r - true if this node is an element, false - otherwise.
isText
r - true if the node is a text node.
isComment
r - true 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.

commonParent
( other: Node ) : Element

Returns common parent of this and other node - nearest element to which these both nodes belong to.