Help Center

Local Navigation

Object: Node

Availability

BlackBerry® Device Software version 4.6 or later

Extended by

Attr, CharacterData, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction

The Node object represents a unique node within the DOM tree. It is the primary data type for the DOM.

While Node exposes methods for dealing with children, not all objects inheriting from Node may have children. For example, Text nodes do not permit children; trying to add children to such nodes results in a DOMException being raised.

The Node.nodeName, Node.nodeValue, and Node.nodeType properties enable you to acquire node information without casting down to the specific child object. In cases where there is no obvious mapping of these properties for a specific nodeType (for example, the Node.nodeValue for an Element, or attributes for a Comment), they return null.

The specialized objects may contain additional and more convenient mechanisms to get and set the relevant information.

Node properties

Property name

Type

Description

Status

Support level

Availability

attributes

NamedNodeMap

Returns a NamedNodeMap object that contains the attributes of the given element node, or null, if the node is not an element.

read only

DOM 2 Core

4.6 or later

childNodes

NodeList

Returns a NodeList object that contains all the child elements of the given node.

read only

DOM 2 Core

4.6 or later

firstChild

Node

Returns the first child of the given node.

read only

DOM 2 Core

4.6 or later

lastChild

Node

Returns the last child of the given node.

read only

DOM 2 Core

4.6 or later

localName

DOMString

Returns the local part of the qualified name for the given node.

read only

DOM 2 Core

4.6 or later

namespaceURI

DOMString

Returns the namespace URI for the given node, or null if it is not specified.

read only

DOM 2 Core

4.6 or later

nextSibling

Node

Returns the node immediately following the given node.

read only

DOM 2 Core

4.6 or later

nodeName

DOMString

Returns the name of the given node.

read only

DOM 2 Core

4.6 or later

nodeType

unsigned short

Returns a code representing the type of the given node.

read only

DOM 2 Core

4.6 or later

nodeValue

DOMString

Specifies the value of the given node.

writable

DOM 2 Core

4.6 or later

ownerDocument

Document

Returns the Document object associated with the given node.

read only

DOM 2 Core

4.6 or later

parentNode

Node

Returns the parent of the given node.

read only

DOM 2 Core

4.6 or later

prefix

DOMString

Specifies the prefix, extracted from the qualified name of the given node, or null if it is unspecified.

writable

DOM 2 Core

4.6 or later

previousSibling

Node

Returns the node immediately preceding the current node.

read only

DOM 2 Core

4.6 or later

Node methods

Method name

Description

Support level

Availability

addEventListener()

Adds an EventListener object to a set of event listeners for the given node.

DOM 2 Events

4.6 or later

appendChild()

Adds a node to the end of the array of child nodes for the given node.

DOM 2 Core

4.6 or later

cloneNode()

Returns a duplicate of the given node. The duplicate node has no parent.

DOM 2 Core

4.6 or later

dispatchEvent()

Dispatches an Event object.

DOM 2 Events

4.6 or later

hasAttributes()

Returns whether the given node has any attributes.

DOM 2 Core

4.6 or later

hasChildNodes()

Returns whether the given node has any children.

DOM 2 Core

4.6 or later

insertBefore()

Inserts a new node before the given node.

DOM 2 Core

4.6 or later

isSupported()

Tests whether the given node supports a specific feature.

DOM 2 Core

4.6 or later

normalize()

Merges text nodes adjacent to the given element node to create a normalized DOM.

DOM 2 Core

4.6 or later

removeChild()

Removes the specified child from the given element node and returns it.

DOM 2 Core

4.6 or later

removeEventListener()

Removes an event listener from an EventTarget.

DOM 2 Events

4.6 or later

replaceChild()

Removes the specified child from the given and replaces it with another node, then returns the removed node.

DOM 2 Core

4.6 or later

Next topic: Object: NodeList
Previous topic: NamedNodeMap methods

Was this information helpful? Send us your comments.