ASP.NET jQuery 實例6 (實現(xiàn)CheckBoxList成員全選或全取消)
更新時間:2012年01月13日 22:36:05 作者:
ASP.NET jQuery 實例6 (實現(xiàn)CheckBoxList成員全選或全取消) ,需要的朋友可以參考下。
這章內(nèi)容比較簡單,直接上頁面代碼:
<%@ 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>
實現(xiàn)全選或全取消操作</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>
復(fù)制代碼 代碼如下:
<%@ 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>
實現(xiàn)全選或全取消操作</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 Javascript獲取CheckBoxList的value
- asp.net+jquery滾動滾動條加載數(shù)據(jù)的下拉控件
- ASP.NET jQuery 實例5 (顯示CheckBoxList成員選中的內(nèi)容)
- ASP.NET jQuery 實例16 通過控件CustomValidator驗證RadioButtonList
- RadioButtonList綁定圖片及泛型Dictionary應(yīng)用
- asp.net CheckBoxList各項最小寬度CSS樣式(兼容性good)
- ASP.NET中用js取CheckBoxList中值的方法實例
- ASP.NET服務(wù)器端控件RadioButtonList,DropDownList,CheckBoxList的取值、賦值用法
- asp.net使用jQuery獲取RadioButtonList成員選中內(nèi)容和值示例
- 如何為CheckBoxList和RadioButtonList添加滾動條
相關(guān)文章
jQuery實現(xiàn)的動態(tài)伸縮導(dǎo)航菜單實例
這篇文章主要介紹了jQuery實現(xiàn)的動態(tài)伸縮導(dǎo)航菜單,實例分析了jQuery鼠標(biāo)事件及animate、hide等方法的使用技巧,需要的朋友可以參考下2015-05-05jquery遍歷table的tr獲取td的值實現(xiàn)方法
下面小編就為大家?guī)硪黄猨query遍歷table的tr獲取td的值實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05jQuery Ajax 實現(xiàn)分頁 kkpager插件實例代碼
本文通過實例代碼給大家講解了jQuery Ajax 實現(xiàn)分頁 kkpager插件功能,需要的的朋友參考下吧2017-08-08jquery分頁插件jquery.pagination.js使用方法解析
這篇文章主要針對js分頁插件jquery.pagination.js使用方法進行解析,很實用的分頁插件,感興趣的小伙伴們可以參考一下2016-04-04jquery實現(xiàn)類似EasyUI的頁面布局可改變左右的寬度
這篇文章主要介紹了通過jquery實現(xiàn)類似EasyUI的頁面布局可改變左右的寬度,需要的朋友可以參考下2014-07-07