Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

HTMLTableRowElement.rowIndex

This article needs a technical review. How you can help.

Naši dobrovolníci ještě tento článek do jazyka Čeština nepřeložili. Přidejte se a pomozte nám tuto práci dokončit!

The HTMLTableRowElement.rowIndex property represents the position of a row in relation to the whole table.

Even when the thead, tbody, and tfoot elements are out of order in the HTML, all main browsers (Chrome, Safari, Firefox, Internet Explorer) except Opera render the table in the right order. Therefore the rows count from thead to tbody, from tbody to tfoot. Opera will give the rowIndex value accordingly to their position within the HTML.

Example

<table>
	<thead>
		<tr>
			<th>Groceries</th>
			<th>Price</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>Bananas</td>
			<td>$2</td>
		</tr>
		<tr>
			<td>Oranges</td>
			<td>$8</td>
		</tr>
		<tr>
			<td>Top Sirloin</td>
			<td>$20</td>
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<td>Total</td>
			<td>$30</td>
		</tr>
	</tfoot>
</table>


Showing the rowIndex value:

var rows = document.getElementsByTagName('tr');

for(var x = 0, xLength = rows.length; x < xLength; x++) {

  alert('rowIndex=' + rows[x].rowIndex);

}

Štítky a přispěvatelé do dokumentace

 Přispěvatelé této stránky: fscholz, teoli, kscarfone, Sheppy, darlesson
 Poslední aktualizace od: fscholz,