jquery selector to count the number of visible table rows?
You can use the :visible
selector and .length
like this:
var numOfVisibleRows = $('tr:visible').length;
If the <table>
itself isn't visible on the screen (:visible
returns false if any parent is hidden, the element doesn't have to be hidden directly), then use .filter()
, like this:
var numOfVisibleRows = $('tr').filter(function() {
return $(this).css('display') !== 'none';
}).length;
$('tr:visible').length
You can also view particular table visible rows
var totalRow = $('#tableID tr:visible').length;
var totalRowWithoutHeader = totalRow-1;
The totalRowWithoutHeader gives the total row count excluding header row.
$("tr:visible") gets you the results of the visible rows, and I think you can then do .length