Skip to content

Functions: Node

Cheton Wu edited this page Apr 6, 2016 · 6 revisions

Index

getChildAt(index)

Gets a child node at the specified index.

Arguments
  1. index (number): The index of the child node.
Returns

(Object): Returns a Node object of the specified child, null otherwise.

Example
node.getChildAt(-1);
// → null
node.getChildAt(0);
// → Node {}

getChildren()

Gets the child nodes.

Returns

(Array): Returns an array of Node objects containing the child nodes.

Example
node.getChildren();
// → [Node {}, Node {}]

getFirstChild()

Gets the first child node.

Returns

(Object): Returns a Node object of the first child, null otherwise.

Example
node.getFirstChild();
// → Node {}

getLastChild()

Gets the last child node.

Returns

(Object): Returns a Node object of the last child, null otherwise.

Example
node.getLastChild();
// → Node {}

getNextSibling()

Gets the next sibling node.

Returns

(Object): Returns a Node object of the next sibling, null otherwise.

Example
node.getNextSibling();
// → Node {}

getParent()

Gets the parent node.

Returns

(Object): Returns a Node object of the parent, null otherwise.

Example
node.getParent();
// → Node {}

getPreviousSibling()

Gets the previous sibling node.

Returns

(Object): Returns a Node object of the previous sibling, null otherwise.

Example
node.getPreviousSibling();
// → Node {}

hasChildren()

Checks whether this node has children.

Returns

(boolean): Returns true if the node has children, false otherwise.

Example
node.hasChildren();
// → true

isLastChild()

Checks whether this node is the last child of its parent.

Returns

(boolean): Returns true if the node is the last child of its parent, false otherwise.

Example
node.isLastChild();
// → true
Clone this wiki locally