HBCMS更多的中文手册参考:

cells Collection

DHTML文档教程

Retrieves a collection of all cells in the table row or in the entire table.

dhtml语法

[ oColl = ] object.cells
[ oObject = ] object.cells(vIndex [, iSubIndex])

DHTML可能的值

oCollArray of td and th elements contained by the object. if the object is a tr, the array contains elements only in that table row. if the object is a table, the array contains all elements in the table.
oobjectreference to an individual item in the array of elements contained by the object.
vindexrequired. integer or string that specifies the element or collection to retrieve. if this parameter is an integer, the method returns the element in the collection at the given position, where the first element has value 0, the second has 1, and so on. if this parameter is a string and there is more than one element with the name or id property equal to the string, the method returns a collection of matching elements.
isubindexoptional. position of an element to retrieve. this parameter is used when vindex is a string. the method uses the string to construct a collection of all elements that have a name or id property equal to the string, and then retrieves from this collection the element at the position specified by isubindex.

members table

PropertyDescription
length Sets or retrieves the number of objects in a collection.
MethodDescription
item Retrieves an object from the all collection or various other collections.
nameditem   Retrieves an object or a collection from the specified collection.
tags Retrieves a collection of objects that have the specified HTML tag name.
urns Retrieves a collection of all objects to which a specified behavior is attached.

remarks

a cells collection is comprised of th and td objects.

when a cell spans multiple rows, that cell appears only in the cells collection for the first of the rows that the cell spans.

if duplicate identifiers are found, a collection of those items is returned. collections of duplicates must be referenced subsequently by ordinal position.

individual cells or an array of cells can be specified using a spreadsheet format. by specifying a colon-delimited string of the starting and ending cells, a cells collection can be retrieved from anywhere in the table. specifying a particular cell with this format returns that object. the format of this string uses letters to indicate columns, starting with a, and numbers to indicate rows, starting with 1. a cells collection on a table row includes only the elements within that row if the vindex string specifies a range of multiple rows using the spreadsheet format.

DHTML代码范例

This example shows how to use the rows collection on the table object 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.oTable.rows.length; i++) {
for (j=0; j < document.all.oTable.rows(i).cells.length; j++) {
document.all.oTable.rows(i).cells(j).innerText = count;
count++;
}
}
}
</SCRIPT>
<BODY onload="numberCells()">
<TABLE id=oTable border=1>
<TR><TH>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH><TH>&nbsp;</TH></TR>
<TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
<TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
</TABLE>
</BODY>
</HTML> 

是否符合公共标准

This collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 Non-Microsoft link.

Applies To

TABLE, TR