<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>Document</title>
  <script type="text/javascript" src="jquery.js"></script> 
 </head>
 <body>
<input type="checkbox" id="selectAll" οnclick="checkAll()" checked>全选
<input type="checkbox" id="11" name="procheck">1选
<input type="checkbox" id="22" name="procheck">2选
<input type="checkbox" id="33" name="procheck">3选
<script>  
function checkAll() 

var checkedOfAll=$("#selectAll").attr("checked"); 
alert(checkedOfAll); 
$("input[name='procheck']").attr("checked", checkedOfAll); 

  
</script>  

<!--prop不可用,还是用attr(火狐,chrome,IE亲测,都不支持prop属性),

有些人的博客里面的东西极不负责任,不试不知道被上当,一试就露马脚,还得自己亲自尝试才放心

 function checkAll() 

var checkedOfAll=$("#selectAll").prop("checked"); 
alert(checkedOfAll); 
$("input[name='procheck']").prop("checked", checkedOfAll); 
}  

-->
 </body>
</html>

本文转载:CSDN博客