Dennis Martinez Dennis Martinez - 3 months ago 20
jQuery Question

How can I get all the tr elements of a table and filter them using jquery?

I'm trying to grab all table rows in a table then filter them out by if they have a class on them titled "hideGroup." This is my code so far but it just keeps outputting numbers. What would be the proper way to grab all the table rows in a table and then check to see if they have a group called "hideGroup?"

var newRows = $("#search-results-table").find("tr");

var filteredRows = newRows.filter(function(n) {
if (n.className != "hideGroup")
return n;


Your question is not that clear.

Use :not() if you like to select all rows that do not have the class

$('#search-results-table tr:not(.hideGroup)')

If you like to only filter the ones with that class use:

$('#search-results-table tr.hideGroup');