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>