JavaScript rows Property Tutorial

In this section, we will learn that the rows property is and how to use it in JavaScript.

What is JavaScript rows Property?

The JavaScript rows property is used to get a reference to the entire rows of a table.

Basically, we call this property using a reference to a <table>, or <tbody>, or <tfoot>, or <thead> and then it will return a collection that contains the entire rows of that section of the table (if it is called using the tbody, thead, tfoot) or the entire rows of the table if it is called using a reference to a <table>.

Note: the rows property is read-only and so we can’t assign a value to it.

Example: JavaScript table row count

See the Pen Untitled by Omid Dehghan (@odchan1) on CodePen.

How does the rows property work in JavaScript?

Here, we’ve called the rows property on top of the <thead> element (which also could be called using a reference to the <table> element itself and then called the `length` property of the collection that returned from this property in order to get the size (the number of rows) on the <thead> element.

Note: please check the cells property section in order to see how this property work.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies