EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

rows property

Retrieves a collection of tr (table row) objects from a table object.

Syntax

JavaScript

p = object.rows

Property values

Type: Element

Array of tr objects.

Standards information

There are no standards that apply here.

Remarks

The scope of the rows collection is for the tHead, tBody, or tFoot object of the table. In addition, there is also a rows collection for the table object, which contains all the rows for the entire table. A row that appears in one of the table sections also appears in the rows collection for the table.

The tr object has two index properties, rowIndex and sectionRowIndex, that indicate where a given row appears. The rowIndex property indicates where the tr appears with respect to the rows collection for the whole table. By contrast, sectionRowIndex returns where the tr appears with respect to the rows collection for the specific table section in which it is located.

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

Examples

This example shows how to use the rows and cells collections to insert a number into each cell of the table.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/rows-cells.htm


<html>

<script type="text/javascript">
function numberCells()
{
	var count=1;
	var oTable = document.getElementById('oTable');
	var RowsLength = oTable.rows.length;
	for (var i=0; i < RowsLength; i++)
	{
	    var oCells = oTable.rows.item(i).cells;
	    var CellsLength = oCells.length;
	    for (var j=0; j < CellsLength; j++) 
	    {
		    oCells.item(j).innerHTML = 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>


 

 

표시:
© 2014 Microsoft