Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / jQuery获取checkboxlist中的value值

先贴代码js代码$("#<%=cbxStyle.ClientID %> input:checkbox").each(function(){
                  if(this.checked==true)
                       alert($(this).parent("span").attr("alt"));
            });.net控件 <asp:CheckBoxList ID="cbxStyle" runat="server" RepeatColumns="3"
                                    RepeatDirection="Horizontal">
                                </asp:CheckBoxList>c# 后台代码cbxStyle.DataSource = ds.Tables[0];
            cbxStyle.DataTextField = "stylename";
            cbxStyle.DataValueField = "styleid";
            cbxStyle.DataBind();            foreach (ListItem li in cbxStyle.Items)
            {
                li.Attributes.Add("alt", li.Value);
            } CheckboxList绑定数据后查看html代码,发现没有value值,只有text值,所以只能通过其他方式来给此控件加个属性,然后通过此属性来间接获取值.