checkbox中的全选中的判断

 for(var i = 0;i<$('input[type=checkbox][name=ListCheckbox]').length;i++){
                    if($('input[type=checkbox][name=ListCheckbox]')[i].disabled== true){
                        //$('input[type=checkbox][name=ListCheckbox]')[i].prop("checked", true);
                        $('input[type=checkbox][name=ListCheckbox]')[i].checked =false;
                        //$(this).attr("checked", true);
                    }else{
                        $('input[type=checkbox][name=ListCheckbox]')[i].checked =true;
                    }
                 }

这时候是选中的全部的checkbox,不能对$('input[type=checkbox][name=ListCheckbox]')[i].prop("checked", true)或者$('input[type=checkbox][name=ListCheckbox]')[i].attr("checked", true);这时候会报错

要进行

$('input[type=checkbox][name=ListCheckbox]')[i].checked = true;  或者
$('input[type=checkbox][name=ListCheckbox]')[i].checked = false;对单个的checkbox标签进行操作

参考:https://q.cnblogs.com/q/76419/

有什么不对的地方请指出来,希望能帮助到大家

猜你喜欢

转载自blog.csdn.net/leibaoxue/article/details/89883170