I have a form and group of checkboxes in it. (These checkboxes are dynamically created but I dont think it is important for this question). The code that generates them look
demo
updated_demo
HTML:
Select all checkbox1 checkbox2 checkbox3 checkbox4
JS:
$('.selectall').click(function() { if ($(this).is(':checked')) { $('div input').attr('checked', true); } else { $('div input').attr('checked', false); } });