HTML | DOM TableRow rowIndex Property
Last Updated :
31 Oct, 2019
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...