Contents Index Topic Contents | ||
Previous Topic: areas Next Topic: children |
cells
Description
Retrieves a collection of all cells in the row of a table. This is a collection of TH and TD elements.
Note When a cell spans multiple rows, that cell appears only in the cells collection for the first of the rows that the cell spans.
Syntax
object.cells(index)
Parameter Description object A TR element. index Optional. An integer or a string specifying the index value of the element to retrieve. Integer indexes are zero-based, meaning the first element in the collection has index 0. A string index is valid only if the string is an identifier of at least one element in the document. Remarks
If duplicate identifiers are found, a collection of those items is returned. Collections of duplicates must subsequently be referenced by ordinal position.
Example
The following example uses the rows collection on the TABLE and the cells collection to insert a number into each cell of the table.
<HTML> <SCRIPT LANGUAGE="JScript"> function numberCells() { var count=0; for (i=0; i < document.all.mytable.rows.length; i++) { for (j=0; j < document.all.mytable.rows(i).cells.length; j++) { document.all.mytable.rows(i).cells(j).innerText = count; count++; } } } </SCRIPT> <BODY onload="numberCells()"> <TABLE id=mytable border=1> <TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> <TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR> </TABLE> </BODY> </HTML>Applies To
Property
Methods
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.