JQuery: count number of rows in a table

countjqueryrow

How do I count the number of tr elements within a table using jQuery?

I know there is a similar question, but I just want the total rows.

Best Answer

Use a selector that will select all the rows and take the length.

var rowCount = $('#myTable tr').length;

Note: this approach also counts all trs of every nested table!