juqery全选反选

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script src="https://cdn.staticfile.org/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>


<input type="checkbox" onclick="choosebox($(this))" >  

<input type="checkbox" name="ids[]"  value="1"> <i></i> 
<input type="checkbox" name="ids[]"  value="2"> <i></i> 
<input type="checkbox" name="ids[]"  value="3"> <i></i>


<script type="text/javascript">
	console.log($(this));
	//全选
    function choosebox(that){ 
        $("input[name='ids[]']").each(function(){
            $(this).prop("checked",that.is(':checked')?true:false);
        });
    }


</script>
</body>
</html>

  

posted @ 2020-10-27 15:53  Abner3721  阅读(50)  评论(0编辑  收藏  举报