\$\begingroup\$
\$\endgroup\$
1
This works:
$('#ShowAll').click(function() {
if ($(this).prop('checked')) {
$('tr.hidden').show(); // todo: There's probably some clever toggle that could be used here.
} else {
$('tr.hidden').hide();
}
});
Is there a one-liner I can be doing instead?
When the user clicks on the ShowAll
checkbox
, then show all the rows that have a class of hidden
, else hide all the rows that have a class of hidden
.
200_success
145k22 gold badges190 silver badges478 bronze badges
asked May 18, 2011 at 13:51
-
1\$\begingroup\$ $('tr.hidden').setHidden(!!$(this).prop('checked')); // or just look for generic method that toggles visibility. Like set css property or something \$\endgroup\$Eimantas– Eimantas2011年05月18日 13:59:03 +00:00Commented May 18, 2011 at 13:59
1 Answer 1
\$\begingroup\$
\$\endgroup\$
.toggle()
exists and seems to do exactly what you want here.
answered May 18, 2011 at 16:50
default