This code snippet will count all the table rows using jQuery and assign it to the rows variable.
var rows = $('#myTable tr').length;
The code searches for the target table with an id of 'myTable', it will then count the total 'tr' tags found.
If you want to avoid heading rows being counted, you can precede the tr with the tbody like so:
var rows = $('#myTable tbody tr').length;
If your code is returning 0 every time, make sure you're executing the code after the page has loaded, you can achieve this with the onload function like so:
$( window ).load(function() {
var rows = $('#myTable tbody tr').length;
});
If you'd like to work with code synthesis on your next project get in touch via the contact page.