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 {

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.

  • 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
    May 18 '11 at 13:59

.toggle() exists and seems to do exactly what you want here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.