I have a construction that checks if a checkbox is checked (who can use more words ‘check’ so close to each other? =)) when the document loads and if it’s checked, some rows in the table get hidden. It looks like this:
if (jQuery('#navbar_disabled').is(':checked')) {
jQuery('#navbar_disabled').parents('tr').prev().hide();
jQuery('#navbar_disabled').parents('tr').prev().prev().hide();
}
I am sure there is a quick nice way to get rid of those 2 last ‘#navbar_disabled’ and use something like ‘this’ or whatever instead. I know I can use something like var navbar_checkbox_disabled=jQuery('#navbar_disabled') and deal with it but I am looking for a more cute solution, if it is there. Thanks.
UPDATE: Why I am asking for the other solution than just assigning it to a new variable is that I need to use it on many elements like this:
jQuery('#company_address_disabled, #sociallinks_disabled, #contacts_mail_disabled, #navbar_disabled')
Why not use it as a filter, which will make the jQuery object empty if it’s not checked: