Tuesday, January 31, 2012

Check and uncheck group of checkboxes

As seen on gmail, when you click on the checkbox on table head it selects all checkboxes in the table. Simple, yet useful!

$('#selectAllCheckbox').click(function(){   

       if($(this).is(':checked')){
             $(this).parents('table').find('input[type="checkbox"]').attr('checked', true);
             }
       else{
            $(this).parents('table').find('input[type="checkbox"]').attr('checked', false);
        }
    });


No comments:

Post a Comment