Jquery中文网 www.jquerycn.cn
Jquery中文网 >  jQuery  >  jquery 教程  >  正文 ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)

ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)

发布时间:2013-06-06   编辑:www.jquerycn.cn
ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消) ,需要的朋友可以参考下。
ASP.NET jquery 实例6 (实现CheckBoxList成员全选或全取消) ,需要的朋友可以参考下。 这章内容比较简单,直接上页面代码:
复制代码 代码如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Recipe6.aspx.cs" Inherits="Recipe6" %>
<!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 runat="server">
<title>Recipe6</title>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#<%=chkSelectAll.ClientID %>").click(function () {
// 很简单,一行代码搞定
$("#<%=chkList.ClientID %> input[type=checkbox]").attr("checked", $("#<%=chkSelectAll.ClientID %>").is(":checked"));
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div align="left">
<p>
实现全选或全取消操作</p>
<fieldset style="width: 400px; height: 150px;">
<asp:CheckBox ID="chkSelectAll" runat="server" Text="全选" />
<hr />
<asp:CheckBoxList ID="chkList" runat="server">
<asp:ListItem Value="1" Text="C#"></asp:ListItem>
<asp:ListItem Value="2" Text="Java"></asp:ListItem>
<asp:ListItem Value="3" Text="C++"></asp:ListItem>
<asp:ListItem Value="4" Text="JavaScript"></asp:ListItem>
</asp:CheckBoxList>
</fieldset>
</div>
</form>
</body>
</html>

效果图:

您可能感兴趣的文章:
ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
JQuery中对服务器控件 DropdownList, RadioButtonList, CheckboxList的操作总结
ASP.NET jQuery 实例5 (显示CheckBoxList成员选中的内容)
CheckBoxList多选样式jquery、C#获取选择项
JQUERY CHECKBOX全选,取消全选,反选方法三
JQuery实现全选与反选的二种方法
ASP.NET中WebForm组件CheckBoxList编程(3)
Jquery选中或取消radio示例
ASP.NET中WebForm组件CheckBoxList编程(1)
ASP.NET jQuery 实例15 通过控件CustomValidator验证CheckBoxList

[关闭]