Javascript DOM HTML TableRow sectionRowIndex Property get

Description

Javascript DOM HTML TableRow sectionRowIndex Property get

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, td {
  border: 1px solid black;
}
</style>/*from  w ww.j a  va  2 s .  co m*/
</head>
<body>
<p id="demo"></p>
<table>
  <thead>
    <tr onclick="myFunction(this)">
      <th>Click to show sectionRowIndex</th>
    </tr>
    <tr onclick="myFunction(this)">
      <th>Click to show sectionRowIndex</th>
    </tr>
    </thead>
    <tbody>
    <tr onclick="myFunction(this)">
      <td>Click to show sectionRowIndex</td>
    </tr>
    <tr onclick="myFunction(this)">
      <td>Click to show sectionRowIndex</td>
    </tr>
    </tbody>
    <tfoot>
    <tr onclick="myFunction(this)">
      <td>Click to show sectionRowIndex</td>
    </tr>
    <tr onclick="myFunction(this)">
      <td>Click to show sectionRowIndex</td>
    </tr>
  </tfoot>
</table>

<script>
function myFunction(x) {
  document.getElementById("demo").innerHTML = "Section row index is: " + x.sectionRowIndex;
}
</script>

</body>
</html>

The sectionRowIndex property returns the position of a row in the rows collection of a <tbody>, <thead>, or <tfoot>.




PreviousNext

Related