The Rows Collection

Note : The Rows collection is Internet Explorer 4.0 specific. For properties, methods and events that are supported by <TR> element, see its topic.

The Rows collection is an ordered, indexed array, containing a reference to every row in contained in the <THEAD>, <TBODY> and <TFOOT> sections of a referenced <TABLE> element. This is a collection containing <TR> elements. Note that the Rows Collection for each <THEAD>, <TBODY>, <TFOOT> and the main <TABLE> element are subtly different. Each <TR> element that specifies a Row in the Rows Collection will have a reference in one of the Rows Collections for either the <THEAD>, <TBODY>, or <TFOOT> elements and a reference in the Rows Collection of the main <TABLE> element.

Rows Objects would normally be retrieved by their index in the Rows collection (for example document.MyTable.rows(3) contains a reference to the 4th row in the table referenced by the MyTable reference (this could be the <TABLE>'s ID attribute), but a string value can be used, as long as that string is a valid identifier (ID attribute value) for a <TABLE> element in the document.



...would return the value of the BGCOLOR attribute for the <TR> element whose ID property is MySecondRow, contained in the <TABLE> element referenced by MyTable


The length property returns the number of <TR> elements in the collection. Note that the length count starts at 1, not 0 as the rows collection index does. Therefore, the length property may return a value of 5, but to access the 3rd row, you'd need to use document.MyTable.rows(2).property


The item method retrieves single items, or sub-collections from the rows collection. It accepts the following arguments:

<TABLE>reference.item(index, sub-index)

If index is a number, then the method returns a reference to the row object at that position in the row collections index.

If the index argument is a string value, then the item method returns a sub-collection, containing a reference to every row in the table that has its ID or NAME attribute set to the string contained in the index argument. To retrieve certain element objects from this sub-collection, the sub-index argument must be used.