62,041
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.2.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<thead>
<tr>
<th>
<input id="chkAllChecked" type="checkbox" name="name" value=" " />
全选
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="checkbox" name="name" value=" " />1</td>
</tr>
<tr>
<td>
<input type="checkbox" name="name" value=" " />2</td>
</tr>
<tr>
<td>
<input type="checkbox" name="name" value=" " />3</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(function () {
$("table > tbody > tr > td input[type='checkbox']").change(function () {
var allSum = $("table > tbody > tr > td input[type='checkbox']").length;
var checkedSum = $("table > tbody > tr > td input[type='checkbox']:checked").length;
if (checkedSum == 0)
$("#chkAllChecked").removeAttr('disabled').removeAttr('checked');
else if (checkedSum == allSum)
$("#chkAllChecked").removeAttr('disabled').attr('checked', 'checked');
else
$("#chkAllChecked").attr('checked', 'checked').attr('disabled', 'disabled');
});
});
</script>
</div>
</form>
</body>
</html>
winform 同理。