JavaScripture
Contribute via GitHub Feedback

Node : EventTarget

Node represents a node in a tree (usually the DOM/document tree). Node is the base type for Element, Text, Document, Comment, and others.

Instance Properties

baseURI : String  

childNodes : NodeList  

A NodeList containing the children Nodes of this. See also Element.children.

Example:

Run

Results:

 

firstChild : Node  

The first child Node in this. If this has no children, firstChild will be null.

Example:

Run

Results:

 

lastChild : Node  

The last child Node in this. If this has no children, lastChild will be null.

Example:

Run

Results:

 

nextSibling : Node  

The sibling Node after this in this.parentNode's children. If this is the last child in parentNode or this has no parentNode, nextSibling will be null.

Example:

Run

Results:

 

nodeName : String  

The name of the node. The value of nodeName depends on the type of this. For Elements, the nodeName is the same as Element.tagName. For ProcessingInstructionss, the nodeName is the same as ProcessingInstruction.target.

Example:

Run

Results:

 

nodeType : Number  

The type of this Node. Will be one of ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE or NOTATION_NODE.

Example:

Run

Results:

 

nodeValue : String

The text content of this (not including any descendants). Note, Elements do not have text content, the text is placed in a Text Node inside the Element. See also textContent.

Example:

Run

Results:

 

ownerDocument : Document  

The Document that owns this Node.

Example:

Run

Results:

 

parentElement : Element  

The parent of this. parentElement will return the same value as parentNode if the parent is also an Element. The document is one Node that is not also an Element.

Example:

Run

Results:

 

parentNode : Node  

The parent of this.

Example:

Run

Results:

 

previousSibling : Node  

The sibling Node before this in this.parentNode's children. If this is the first child in parentNode or this has no parentNode, previousSibling will be null.

Example:

Run

Results:

 

textContent : String

The text content of this node and all descendants. See also nodeValue.

Example:

Run

Results:

 

Instance Methods

appendChild(newChild : Node) : Node

Inserts newChild at the end of the children of this. Returns newChild. See also insertBefore(), removeChild(), and replaceChild().

Example:

Run

Results:

 

cloneNode(deep : Boolean) : Node

Creates a copy of this. Only the attributes of the element are copied (any other properties set will not be copied). If deep is true, all descendants will be copied and added as children of the clone. Otherwise the returned value will not have children.

Example:

Run

Results:

 

compareDocumentPosition(other : Node) : Number

Returns a value that indicates where other is relative to this. The return value will be a number that is the bitwise AND (&) of one or more of the following values: DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, or DOCUMENT_POSITION_PRECEDING.

Example:

Run

Results:

 

contains(other : Node) : Boolean

Returns true if other is a descendant of this.

Example:

Run

Results:

 

hasChildNodes() : Boolean

Returns true if this has children.

Example:

Run

Results:

 

insertBefore(newChild : Node, [refChild : Node]) : Node

Inserts newChild before refChild in this. If refChild is not provided, newChild is inserted at the end of the children. Returns newChild. See also appendChild(), removeChild(), and replaceChild().

Example:

Run

Results:

 

isDefaultNamespace(namespaceURI : Boolean) : Boolean

isEqualNode(arg : Node) : Boolean

lookupNamespaceURI(prefix : String) : String

lookupPrefix(namespaceURI : String) : String

normalize() : undefined

Removes empty Text nodes within this and joins adjacent Text nodes into one node.

Example:

Run

Results:

 

removeChild(oldChild : Node) : Node

Removes oldChild from the children of this. Returns oldChild. See also appendChild(), insertBefore(), and replaceChild().

Example:

Run

Results:

 

replaceChild(newChild : Node, oldChild : Node) : Node

Removes oldChild from the children of this and replaces it with newChild (so newChild is in the same position as oldChild was). Returns oldChild. See also appendChild(), insertBefore(), and removeChild().

Example:

Run

Results:

 

Node Properties

ATTRIBUTE_NODE : Number  

Returned by nodeType when this is an Attr.

Example:

Run

Results:

 

CDATA_SECTION_NODE : Number  

Returned by nodeType when this is an CDATA node.

COMMENT_NODE : Number  

Returned by nodeType when this is a Comment.

Example:

Run

Results:

 

DOCUMENT_FRAGMENT_NODE : Number  

Returned by nodeType when this is a DocumentFragment.

Example:

Run

Results:

 

DOCUMENT_NODE : Number  

Returned by nodeType when this is a Document.

Example:

Run

Results:

 

DOCUMENT_POSITION_CONTAINED_BY : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_POSITION_CONTAINS : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_POSITION_DISCONNECTED : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_POSITION_FOLLOWING : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_POSITION_PRECEDING : Number  

Bitmask value returned by compareDocumentPosition().

DOCUMENT_TYPE_NODE : Number  

Returned by nodeType when this is a DocumentType.

Example:

Run

Results:

 

ELEMENT_NODE : Number  

Returned by nodeType when this is an Element.

Example:

Run

Results:

 

ENTITY_NODE : Number  

Returned by nodeType when this is an entity node.

ENTITY_REFERENCE_NODE : Number  

Returned by nodeType when this is an entity reference node.

NOTATION_NODE : Number  

Returned by nodeType when this is a notation node.

PROCESSING_INSTRUCTION_NODE : Number  

Returned by nodeType when this is a ProcessingInstruction.

Example:

Run

Results:

 

TEXT_NODE : Number  

Returned by nodeType when this is an Text.

Example:

Run

Results: