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值,所以只能通过其他方式来给此控件加个属性,然后通过此属性来间接获取值.

posted @ 2013-06-17 17:20  qingzhouyi  阅读(258)  评论(0编辑  收藏  举报