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

  • 相关阅读:
    函数
    数值
    数据类型
    jQuery工具方法
    jQuery概述
    史上最全的SpringMVC学习笔记
    webpack-Hot Module Replacement(热更新)
    webpack-Manifest
    webpack-Targets(构建目标)
    webpack-Dependency Graph(依赖图)
  • 原文地址:https://www.cnblogs.com/qingzhouyi/p/3140697.html
Copyright © 2011-2022 走看看