Phillip Senn
Phillip Senn

Reputation: 47605

Hide every row except the one selected

I have a bunch of table rows with radio inputs:

<tr>
<td>
<input name="myRadio" type="radio" value="1">
</td>
</tr>

Q: How do hide all the rows that are not this row when it is selected?

$('input').filter(':radio').change(function() {
$('tr').find(not this).hide();
});

Upvotes: 2

Views: 213

Answers (3)

zdrsh
zdrsh

Reputation: 1667

$('input').filter(':radio').change(function() {
  $('tr, input:not(:checked)').hide();
});

example here

Upvotes: 1

Sarfraz
Sarfraz

Reputation: 382696

Try:

$('input').filter(':radio').change(function() {
  $(this).closest('tr').siblings('tr').hide();
});

Upvotes: 2

aziz punjani
aziz punjani

Reputation: 25776

$('input').filter(':radio').change(function() {
    $('tr').not( $(this).closest('tr') ).hide();
});

Upvotes: 1

Related Questions