<!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.js" type="text/javascript"></script>
<script>function selectAll(obj)
{
if(obj.checked==true)
{
$(":checkbox").filter("[name=my]").get().checked = true;
}
else
{
$(":checkbox").filter("[name=my]").get().checked = false;
}
}</script>
</head>
<body>
<input name="my" type="checkbox" value="1">图选1</input>
<input name="my" type="checkbox" value="2">图选2</input>
<input name="my" type="checkbox" value="3">图选3</input>
<input name="my" type="checkbox" value="4">图选4</input>
<br/><br/>
<input type="checkbox" onclick="selectAll(this)">全选/取消</input>
</body>
</html>
<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.js" type="text/javascript"></script>
<script>function selectAll(obj)
{
if(obj.checked==true)
{
$(":checkbox").filter("[name=my]").get().checked = true;
}
else
{
$(":checkbox").filter("[name=my]").get().checked = false;
}
}</script>
</head>
<body>
<input name="my" type="checkbox" value="1">图选1</input>
<input name="my" type="checkbox" value="2">图选2</input>
<input name="my" type="checkbox" value="3">图选3</input>
<input name="my" type="checkbox" value="4">图选4</input>
<br/><br/>
<input type="checkbox" onclick="selectAll(this)">全选/取消</input>
</body>
</html>
<!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 type="text/javascript" src="Script/jquery-1.3.2.js"></script></head>
<body>
<input name="my" type="checkbox" value="1">图选1</input>
<input name="my" type="checkbox" value="2">图选2</input>
<input name="my" type="checkbox" value="3">图选3</input>
<input name="my" type="checkbox" value="4">图选4</input>
<br />
<br />
<input id="inputChkAll" type="checkbox">全选/取消</input> <script type="text/javascript"> $('#inputChkAll').click(function() {
$("input[name='my']").attr("checked", $(this).attr("checked"));
}); </script>
</body>
</html>
alert( $(":checkbox").filter("[name=my]").get().length)
if (obj.checked == true) {
$(":checkbox").filter("[name=my]").get().checked = true;
// $(":checkbox[name='my']").attr("checked",true);
} else {
$(":checkbox").filter("[name=my]").get().checked = false;
// $(":checkbox[name='my']").removeAttr("checked");
}
}
{
if(obj.checked==true)
{
$("input:checkbox").filter("[name=my]").each(function(){this.checked=true});
}
else
{
$("input:checkbox").filter("[name=my]").each(function(){this.checked=false});
}
}</script>[/code]