jqeury checkbox全选/反选 ,子选项全选,全选选中

来源:互联网 发布:thinkphp oa系统源码 编辑:程序博客网 时间:2024/06/05 10:11
// 全选/反选
$('input[name="checkall"]').click(function() {    $('input[name="checkone"]').prop("checked", this.checked); });//子选项全选,全选选中$('input[name="checkone"]').click(function() {    var length = $('input[name="checkone"]').length;    var num = 0;    $("input[name='checkone']").each(function(){        one_checkd = $(this).prop('checked');        if(one_checkd == true){            num++;        }    });    if (length == num) {        $('input[name="checkall"]').prop('checked', true);    }else{        $('input[name="checkall"]').prop('checked', false);    };});