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以上版本

posted @ 2015-05-22 12:38  我就是小代  阅读(236)  评论(0编辑  收藏  举报