I have a table like this:
<table class="tableclass">
<tbody>
<tr>
<th>..</th>
<th>..</th>
</tr>
<tr class="odd">
<td>..<</td>
<td>..<</td>
</tr>
<tr class="even">
<td>..<</td>
<td>..<</td>
</tr>
<tr class="odd current">
<td>..<</td>
<td>..<</td>
</tr>
</tbody>
</table>
There are many tr that have odd or even class, and they can be before or after tr that has current class.
I want to hide all but two rows below:
-
The row (tr) that has “current” class
-
The row (tr) that has <th>
In other words, I want the table becomes
<table class="tableclass">
<tbody>
<tr>
<th>..</th>
<th>..</th>
</tr>
<tr class="odd current">
<td>..<</td>
<td>..<</td>
</tr>
</tbody>
</table>
I try to use
$("table.tableclass tr:not(.current)").hide();
But it hides tr that has th inside too.
Is there an AND operator? Something like
$("table.tableclass tr:not(.current) AND tr:not(WITH NO CLASS)").hide();
you need to scope your selector to hide only odd/even classes but not current. so you are almost there.