checkbox 全选和全不选

1 jsp页面

  <input id="selectCheckBoxAllChk"  type="checkbox">

2 js

  //绑定复选框全选事件
    $("#selectCheckBoxAllChk").bind("click",function(){
        if($(this).prop("checked")){
            $("input[type='checkbox']").prop("checked", 'true');
        }else{
            $("input[type='checkbox']").removeAttr("checked");
        }
    });

注:需要引入jquery.js以上版本

原文地址:https://www.cnblogs.com/wdlove/p/4522019.html