您的位置:首页 > Web前端 > JQuery

jQuery实现checkboxlist的全选/全不选

2010-06-04 18:08 549 查看
HTML Code:

代码

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var checkItem=function(index)
{
if(index==1)
{
$("#chkCRREQ :checkbox").each(function(){$(this).attr("checked",true);});
}
else
{
$("#chkCRREQ :checkbox").each(function(){$(this).attr("checked",false);});
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table  style="width:100%;" border="1">
<tr>
<td colspan="3" align="center" style="font-size:larger;">CRREQ</td>
</tr>
<tr>
<td colspan="3">
<input id="btnSelect" type="button" onclick="checkItem(1)" value="select all" />
<input id="btndeselect" type="button" onclick="checkItem(2)" value="deselect all" />
</td>
</tr>
<tr>
<td>
<asp:CheckBoxList ID="chkCRREQ" runat="server"  RepeatColumns="3" RepeatDirection="Horizontal" Width="100%">
</asp:CheckBoxList>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: