Collection object (Object/DOM)

An array of Element objects.

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Opera browser - 3.0
JavaScript syntax:IEmyCollection = myDocument.all
IEmyCollection = myDocument.children
IEmyCollection = myDocument.filters
-myCollection = myDocument.getElementsByName(aName)[anIndex]
IEmyCollection = myElement.all
IEmyCollection = myElement.children
IEmyCollection = myElement.filters
-myCollection = myDocument.getElementsByTagName(aTag)[anIndex]
Argument list:aNameThe name attribute of an element
anIndexA valid reference to an item in the collection
aTagThe name of a tag
Object properties:length
Object methods:Item(), namedItem(), tags()

A collection object is an enhancement to the basic array object to provide some additional searching capabilities for managing the contents of the document object model in a web browser.

Do not confuse DOM NodeList arrays with Enumerator or Collection objects. The NodeListitem() method is subtly different from the Enumerator.Item() method.

See also:TABLE.cells[]

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
length1.5 1.53.0 3.06.0 6.04.0 4.03.0 3.0 n/a n/a1 1 n/a n/aReadOnly

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
Item()1.5 1.53.0 3.06.0 6.04.0 4.05.0 5.0 n/a n/a1 1 n/a n/aWarning
namedItem()1.5 1.55.0 5.06.0 6.05.0 5.05.0 5.0 n/a n/a1 1 n/a n/a-
tags() n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-