if (Drupal.jsEnabled) { $(document).ready(function () { $("table.package tr").click( function() { $(this).find("input").check("toggle"); }); }); } $.fn.check = function(mode) { var mode = mode || 'on'; return this.each( function() { switch(mode) { case 'on': this.checked = true; break; case 'off': this.checked = false; break; case 'toggle': this.checked = !this.checked; break; } }); };