<!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=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.4.2.min.js"></script>
<script language="javascript" type="text/javascript">
 function checkAll(){
   jQuery(":checkbox").attr("checked","checked");
  }
 function unCheckAll(){
   jQuery(":checkbox").attr("checked","");
  }
 function checkedAll(){
   var arr = jQuery(':checkbox');
   for(var i=0;i<arr.length;i++){
   arr[i].checked = ! arr[i].checked;
   }
  }
</script>
</head>

<body>
<input type="checkbox" id="p1" /><label for="p1">天使座</label>
<input type="checkbox" id="p2" /><label for="p2">狮子座</label>
<input type="checkbox" id="p3" /><label for="p3">白羊座</label>
<p>
<input type="button" name="checkAll" value="全选" onclick="checkAll()"/>
<input type="button" name="unCheckAll" value="全不选" onclick="unCheckAll()"/>
<input type="button" name="checkedAll" value="反选"  onclick="checkedAll()"/>
</p>
</body>
</html>

posted on 2011-04-09 17:12  轻盈  阅读(909)  评论(0编辑  收藏  举报