jquery 使用prop() checkbox全选:
<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <link rel="icon" href="favicon.ico"> <title></title> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script></head><body><input type="checkbox" id="all"> 全选<div> <input type="checkbox"> 类别1 <input type="checkbox"> 类别2 <input type="checkbox"> 类别3 <input type="checkbox"> 类别4</div><script> $(function () { $('#all').click(function(){ $(this).siblings('div').find('input[type=checkbox]').prop('checked',$(this).prop('checked')); }) })</script></body></html>