开发者

Hide every row except the one selected

开发者 https://www.devze.com 2023-04-13 08:08 出处:网络
I have a bunch of table rows with radio inputs: <tr> <td> <input na开发者_如何转开发me=\"myRadio\" type=\"radio\" value=\"1\">

I have a bunch of table rows with radio inputs:

<tr>
<td>
<input na开发者_如何转开发me="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();
});


Try:

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


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


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

example here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号