I want to check all checkboxes when 'Select all' checkbox is checked. I've read various threads on SO, but not able to get the expected o/p.
Related Question:- Select all checkboxes with jQuery
Here's what I tried.
<div class="row-fluid" id="set_alarm">
<label class="checkbox inline"><input type="checkbox" id="select_all"><b>Select All</b></label><br>
<label class="checkbox inline days"><input type="checkbox" id="Mon"><b>Mon</b></label>
<label class="checkbox inline days"><input type="checkbox" id="Tue"><b>Tue</b></label>
......
......
</div>
jQuery
$('#select_all').change(function() {
var checkboxes = $(this).closest('.days').find(':checkbox');
if($(this).is(':checked')) {
checkboxes.attr('checked', 'checked');
} else {
checkboxes.removeAttr('checked');
}
});