Hide every row except the one selected
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
精彩评论