<th><input type="checkbox" class="checkAll"></th>
<td><input type="checkbox" class="checks" value="{$val.id}"></td>
// 全选全不选 $('.checkAll').click(function (){ $('.checks').prop('checked',$(this).prop('checked')) }); // 批量删除 $('.delData').click(function (){ var ids=[]; $('.checks:checked').each(function (){ ids.push($(this).val()); }) $.ajax({ url:"delData", type:'get', data:{id:ids}, dataType:'json', success:function(e){ if(e.code==200){ // console.log(e); $('.checks:checked').each(function (){ $(this).parents('tr').remove(); }) } if(e.code==400){ alert('批量删除失败') } }}); })
// 批量删除 function delData(){ $id=input('get.id'); // dd($id); $obj=new \app\model\Index(); $res=$obj->delData($id); if($res){ return json([ 'code'=>200 ]); }else{ return json([ 'code'=>400 ]); } }
//批量删除 function delData($id){ return $this->destroy($id); }