Reputation: 1363
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();
Upvotes: 0
Views: 394
Reputation: 6682
Why not change <tr><th></th></tr>
to <thead><th></th></thead>
and move this above the <tbody></tbody>
? Anyway, it should be there.
Upvotes: 0
Reputation: 5720
you need to scope your selector to hide only odd/even classes but not current. so you are almost there.
$("table.tableclass tr.odd:not(.current), table.tableclass tr.even:not(.current)").hide()
Upvotes: 1
Reputation: 28763
Try like this
$("table .odd,.even").hide()
or individually you can hide like
$(".odd").hide();
$(".even").hide();
Upvotes: 0