<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="content-type" content="text/html" charset="utf8">
<title></title>
/*要添加好jquery库*/
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script src="jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript">
function checkAll() {
$("input:checkbox").attr("checked","true");
}
function uncheckAll() {
$("input:checkbox").each(function(){
this.checked=false;
})
}
</script>
</head>
<body>
<input type="checkbox" id="in1" />1<br />
<input type="checkbox" id="in2" />2<br />
<input type="checkbox" id="in3" />3<br />
<p>
<input type="button" name="checkAll" value="全选" />
<input type="button" name="uncheckAll" value="取消" />
</p>
</body>
</html>
转载于:https://blog.51cto.com/2913221/945434