laravel 全选反选

给input设置一个class

<input type="checkbox" class="all">
@foreach($info as $v)
 <tr align="center">
    <td>
    <input type="checkbox" value="{{$v->id}}" class="ids" name="check">
     </td>
    <td  class="id">
     {{$v->id}}
     </td>
 </tr>
@endforeach                

jq事件

<script src="jq.js">
	//当点击设置好的class
	$('.all').click(function(){
		if (this.checked) {  ////this指当前对象

            $("[name=check]:checkbox").prop("checked", true); 
        }else {

            $("[name=check]:checkbox").prop("checked", false);
        }	
		
	})
</script>

猜你喜欢

转载自blog.csdn.net/qq_43638176/article/details/86672715