ASP.NET jQuery 食谱5 (显示CheckBoxList成员选中的内容)
2012-01-12 21:21
931 查看
这章我们主要看下如何通过jQuery来获取CheckBoxList成员内容。
界面代码:
显示效果:
实现选中语言并显示内容脚本代码:
选中语言后界面:
界面代码:
<form id="form1" runat="server"> <div align="left"> <fieldset style="width: 400px; height: 150px"> <p> 请选择语言</p> <asp:CheckBoxList ID="ckbListPro" 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> <br /> <div id="message" style="color:Red;"></div> </div> </form>
显示效果:
实现选中语言并显示内容脚本代码:
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { // CheckBoxList在页面呈现时转换为<table id="ckbListPro"> // 成员ListItem转换为<input type="checkbox"><label> $("#<%=ckbListPro.ClientID %>").click(function () { var str = ""; // 这里获取到被选中的<input type="checkbox"> $("#<%=ckbListPro.ClientID %> input[type=checkbox]:checked").each(function () { str = str + $(this).val() + ":" + $(this).next().text() + " "; // 这里的next()表示<label> }); $("#message").text(str); }); }); </script>
选中语言后界面:
相关文章推荐
- ASP.NET jQuery 实例5 (显示CheckBoxList成员选中的内容)
- ASP.NET jQuery 实例5 (显示CheckBoxList成员选中的内容)
- ASP.NET jQuery 随笔 显示CheckBoxList成员选中的内容
- ASP.NET jQuery 随笔 显示RadioButtonList成员选中的内容和值
- ASP.NET jQuery 食谱6 (实现CheckBoxList成员全选或全取消)
- ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
- asp.net绑定checkboxlist--------jquery绑定click事件,获取checkbox的value和显示值
- ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
- ASP.NET绑定CHECKBOXLIST--------JQUERY绑定CLICK事件,获取CHECKBOX的VALUE和显示值
- asp.net使用jQuery获取RadioButtonList成员选中内容和值示例
- asp.net使用jQuery获取RadioButtonList成员选中内容和值示例
- asp.net绑定checkboxlist--------jquery绑定click事件,获取checkbox的value和显示值
- ASP.NET jQuery 食谱15 (通过控件CustomValidator验证CheckBoxList)
- C#中??和?分别是什么意思? 在ASP.NET开发中一些单词的标准缩写 C#SESSION丢失问题的解决办法 在C#中INTERFACE与ABSTRACT CLASS的区别 SQL命令语句小技巧 JQUERY判断CHECKBOX是否选中三种方法 JS中!=、==、!==、===的用法和区别 在对象比较中,对象相等和对象一致分别指的是什么?
- Jquery 获取Asp.Net CheckBoxList的Value,Text
- ASP.NET改变checkboxlist选中项字体颜色
- ASP.NET CheckBoxList Operations with jQuery
- asp.net CheckBoxList 取值与是否选中,后台控制前台checkboxList选中
- 用JavaScript获取Asp.net服务器端控件CheckBoxList的选中值数组
- ASP.NET CheckBoxList Operations with jQuery