Retrieves the position of the object in the rows collection for the table.
dhtml语法
html | n/a |
---|
scripting | [ iindex = ] tr.rowindex |
---|
dhtml可能的值
iIndex | Integer that
receives Integerthat specifies the index number. |
The property is read-only.
The property has no default value.
Remarks
This property is different from sectionrowindex, which indicates the object's position in the tbody, thead, or tfoot?b>rows collection. these sections are mutually exclusive, so the tr is always contained in one of these sections and in the table. you can determine the rowindex property of an object by the order in which the object appears in the html source.
DHTML代码范例
This example function shows how to use the rowIndex attribute to format a table. The function sets the background color of the rows in the table to black or white, alternating row by row.
function formatTable(oTable)
{
var rows=oTable.rows;
for(var i=0;i<rows.length;i++)
{
if(i%2==0) {
rows[i].style.backgroundColor = "black";
rows[i].style.color = "white";
} else {
rows[i].style.backgroundColor = "white";
rows[i].style.color = "black";
}
}
}
是否符合公共标准
This property is defined in
World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
更多语法参考
cellindex, sourceIndex