1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 5 <title>Demo</title> 6 <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> 7 </head> 8 <body> 9 <p><input type="checkbox" />##############0</p> 10 <p><input type="checkbox" />##############1</p> 11 <p><input type="checkbox" />##############2</p> 12 <p><input type="checkbox" />##############3</p> 13 <p><input type="checkbox" />##############4</p> 14 <p><input type="checkbox" />##############5</p> 15 <button>全选</button> 16 <button>反选</button> 17 <button>全不选</button> 18 <button>删除</button> 19 </body> 20 <script> 21 $('button:first').click(function(){ 22 $(':checkbox').attr('checked',true); 23 }).next().click(function(){ 24 $(':checkbox').each(function(){ 25 $(this).prop('checked',!$(this).prop('checked')); 26 }); 27 }).next().click(function(){ 28 29 $(':checkbox').attr('checked',false); 30 }).next().click(function(){ 31 $(':checked').parent().remove(); 32 }) 33 34 </script> 35 </html>