Select / deselect all checkbox for iCheck plugin


ashokg165

Icheck is highly customizable checkboxes and radio buttons for jQuery and Zepto.

$(function () {
var checkAll = $(‘input.all’);
var checkboxes = $(‘input.check’);

$(‘input’).iCheck();

checkAll.on(‘ifChecked ifUnchecked’, function(event) {
if (event.type == ‘ifChecked’) {
checkboxes.iCheck(‘check’);
} else {
checkboxes.iCheck(‘uncheck’);
}
});

checkboxes.on(‘ifChanged’, function(event){
if(checkboxes.filter(‘:checked’).length == checkboxes.length) {
checkAll.prop(‘checked’, ‘checked’);
} else {
checkAll.removeProp(‘checked’);
}
checkAll.iCheck(‘update’);
});
});

View original post