iCheck单选全选

来源:互联网 发布:批量注册淘宝小号软件 编辑:程序博客网 时间:2024/05/28 16:19
var checkboxs = $(".subCheck") var mainbox = $("#mainCheck") mainbox.on("ifChecked ifUnchecked",function(event){ if(event.type == 'ifChecked'){ checkboxs.iCheck('check'); }else{ checkboxs.iCheck('uncheck'); } }); checkboxs.on('ifChanged',function(event){ //下面的是用子选项控制mainbox的业务逻辑 if(checkboxs.filter(':checked').length == checkboxs.length) {     mainbox.prop('checked',true); } else { mainbox.prop('checked',false); } mainbox.iCheck('update') });  //删除操作$("#delete").on('click',function(){var str="";var ids="";checkboxs.each(function(){if(true == $(this).is(':checked')){str += $(this).data('id')+",";}});if(str.substr(str.length-1)== ','){ids = str.substr(0,str.length-1);}console.log(ids);});