Open In App

HTML | DOM TableRow rowIndex Property

The TableRow rowIndex property in HTML DOM is used to return the position and index of row among the collection of rows.

Syntax: It returns the rowIndex property.



tablerowObject.rowIndex

Return Value: It returns the numeric value which represents the position of a row in the rows collection of a table.

Example:




<!DOCTYPE html> 
<html
      
<head
    <title>
        HTML DOM tableRow rowIndex Property
    </title>
      
    <style
        table, th, td { 
            border: 1px solid green; 
        
    </style
</head
  
<body
    <h1
        GeeksForGeeks 
    </h1
          
    <h2>HTML DOM tableRow rowIndex Property</h2
      
    <p
        Click on the row to get the
        index of the rows
    </p>
      
    <table
        <tr id = "GFG" onclick="myGeeks(this)"
            <td>Geeks</td
            <td>Geeks</td
            <td>For</td
            <td>Geeks</td
        </tr
        <tr id = "GFG" onclick="myGeeks(this)"
            <td>Geeks</td
            <td>Geeks</td
            <td>For</td
            <td>Geeks</td
        </tr
        <tr id = "GFG" onclick="myGeeks(this)"
            <td>Geeks</td
            <td>Geeks</td
            <td>For</td
            <td>Geeks</td
        </tr
    </table
  
    <p id = "sudo"></p>
  
    <script
        function myGeeks(x) {
            alert("Row index is: " + x.rowIndex);
        }
    </script>
</body
  
</html>

Output:



Supported Browsers: The browsers supported by HTML DOM tableRow rowIndex property are listed below:


Article Tags :