Chapter 3 DynaScript Predefined Objects


DOMNodeList object

Object

Represents an ordered collection of nodes.

Syntax

To use a DOMNodeList's property:

DOMNodeList.propertyName

To use a DOMNodeList's method:

DOMNodeList.MethodName( parameter ) 

Description

The DOMNodeList object represents an ordered collection of DOMNode objects, or any object that inherits from DOMNode . The objects on the node list are accessible via an integral index. Index values start at zero.

length property

Syntax

DOMNodeList.length

Description

The number of objects in the list.

Example

This fragment loops through the items of a DOMNodeList of elements:

for( iElem=0; 
     iElem < domParent.childNodes.length; 
     iElem++ ) {
  thisChild = domParent.childNodes.item( iElem );
  // other operations here
}

item method

Syntax

DOMNodeList.item( index )

Description

Returns the indexth item in the collection. Valid values for index are 0 through length minus 1.

Return

The node at the indexth position or null if the index is invalid

Example

This fragment loops through the items of a DOMNodeList of elements:

for( iElem=0; 
     iElem < domParent.childNodes.length; 
     iElem++ ) {
  thisChild = domParent.childNodes.item( iElem );
  // other operations here
}

 


Copyright © 2001 Sybase, Inc. All rights reserved.