zoukankan      html  css  js  c++  java
  • Jquery获得服务器控件的方法

    由于ASP.NET网页运行后,服务器控件会随机生成客户端id,jquery获取时候不太好操作,google了下,总结有以下3种方法:
    
    
    服务器控件代码:
    <asp:TextBox ID="txtUserID" runat="server"></asp:TextBox> 
    
    1. $("#<%=txtUserID.ClientID%>");
    
    2. $("input[id*=txtUserID]");
    
    3. $("*[id$=txtUserID]");
    eg:
    <script type="text/javascript">
        $(document).ready(function () {
            $("#CheckBox1").click(function () {
                if ($("#CheckBox1").is(":checked")) {
                    $("#<%=ImageButton1.ClientID%>").removeAttr("disabled");
                }
                else
                    $("#<%=ImageButton1.ClientID%>").attr("disabled", true);
            });
        });
    </script>
                        <li class="clearfloat">
                                    <div class="left set_tip_width Reg_font_title3">
                        &nbsp;服务条款:
                        </div>
                            <div class="left Reg_font_title4">
                            <div>
                                <input id="CheckBox1" type="checkbox" checked="checked" />我已经阅读并同意  <a  href="Rule.aspx" target="_blank">会员注册协议</a>
                            </div>
                            </div>
                        </li>
                        <div class="clearfloat t_center" style="margin:10px 0 20px 0;">
                            <asp:Button ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" OnClientClick="return checkrule();"
                                    CssClass="mouse"   width="60" height="25" Text="注册报名" />
                        </div>  

  • 相关阅读:
    Binary Tree Paths
    Implement Stack using Queues
    Path Sum II
    Path Sum
    Plus One
    Add Digits
    Missing Number
    H-Index II
    H-Index
    Ugly Number II
  • 原文地址:https://www.cnblogs.com/vinsonLu/p/3831557.html
Copyright © 2011-2022 走看看