jQuery - Get table row count with a certain class

javascript, jquery

Solution

Simply add the class to the selector

var rows= $('#myTable tbody tr.MyClass').length;

Problem

I know I can get the number of rows in an HTML table with the following jQuery: ``` var rows= $('#myTable tbody tr').length; ``` However, how can I get the number of rows that have a given class (e.g., `<tr class="MyClass>`). How can I count the number of rows in a table with a class of "MyClass"?

Original source