tr rowIndexPropriété

tr 对象参考手册Objet tr

Définition et utilisation

La propriété rowIndex renvoie une ligne (rows) dans la collection de lignes du tableau (index de ligne).

Syntaxe

Renvoie la propriété rowIndex :

trObject.rowIndex

Astuce :La propriété rowIndex n'a pas de valeur par défaut.


Prise en charge des navigateurs

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Tous les principaux navigateurs prennent en charge la propriété rowIndex.


Exemple

Exemple

L'exemple suivant renvoie la position d'une ligne dans le tableau :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Exemple (example.com)</title>
<script>
function displayResult(x){
    alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>

<table border="1">
    <tr onclick="displayResult(this)">
<td>Cliquez pour afficher l'index de ligne</td>
    </tr>
    <tr onclick="displayResult(this)">
<td>Cliquez pour afficher l'index de ligne</td>
    </tr>
    <tr onclick="displayResult(this)">
<td>Cliquez pour afficher l'index de ligne</td>
    </tr>
</table>

</body>
</html>

Essayez-le vous-même »


tr 对象参考手册Objet tr Autres extensions