Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM TableRow rowIndex Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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:

  • Before Clicking on Row element:
  • After Clicking on Row element:

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

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Last Updated : 31 Oct, 2019
Like Article
Save Article
Similar Reads
Related Tutorials