HTML | DOM Table rows Collection
The Table rows collection is used for returning the collection of all the <tr> elements in a table. The sequence of the <tr> elements are sorted in the same way as their position in the source code.
- length : It is used to return the number of <tr> elements in the collection.
- [index] : It is used for returning the <tr> element from the collection with a specified index.
- item(index) : It is also used for returning the <tr> element from the collection with a specified index.
- namedItem(id) : It is also used for returning the <tr> element from the collection with a specified id.
Below program illustrates the Table rows collection :
Example: Finding out the number of rows in a table.
Before clicking the button:
After clicking the button:
- Apple Safari
- Internet Explorer
- Google Chrome
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.