Jquery 网站后台常用的全选功能

2818

网站常用Jquery全选 删除、修改等操作:

Html:基本样式操作:

<thead>
<tr><th width="8%" scope="col"><input class="arrid" type="checkbox" />全选</th></th>
</tr>
</thead>
<tbody>
 <tr>
  <td width="5%" class="posi"><input type="checkbox" class="checkAll" name="checkbox" /><span class="uid color-FF">1</span>
  </tr>
 <tr>
  <td width="5%" class="posi"><input type="checkbox" class="checkAll" name="checkbox" /><span class="uid color-FF">2</span>
  </tr>
</tbody>
//全选
$(".checkA").on('click', function(){
    $(".arrtcheck").prop("checked", this.checked);
 });
 
$(".arrid").on('click', function(){
    var option = $(".arrid");
    option.each(function(i){
        if(!this.checked){
            $(".checkAll").prop("checked", false);
            return false;
        }else{
            $(".checkAll").prop("checked", true);
        }
    });
});