【问题标题】:Set hidden <asp:Label> visible with jQuery show()使用 jQuery show() 设置隐藏的 <asp:Label> 可见
【发布时间】:2016-06-27 06:20:38
【问题描述】:

有没有办法设置&lt;asp:Label&gt; 被jQuery 可见?

我有一个这样的标签:

<asp:Label runat="server" ID="lblCheckboxesError" Text="test" visible="false"></asp:Label>

在 js 文件中我有这个:

$("[id*=lblCheckboxesError]").show();

但它没有显示。我尝试了一些解决方案,但对我没有任何作用。任何想法?谢谢:)

【问题讨论】:

    标签: jquery asp.net label


    【解决方案1】:

    改用style="display:none;"

    <asp:Label runat="server" ID="lblCheckboxesError" Text="test" 
       style="display:none;"></asp:Label>
    

    visible="false" 在服务器中运行(服务器不会将元素发送到浏览器)

    style="display:none;" 在浏览器中隐藏元素,因此 jQuery 的 show() 可以工作。

    【讨论】:

      【解决方案2】:
      Make sure the id is generated with same as given "lblCheckboxesError" in the html and style is set as "display:none" as show/hide acts on display property of style attribute. Then you could access the control as:
      
      $('#lblCheckboxesError').show();
      

      模板:$('#ID').show()

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-25
        • 2014-05-02
        • 1970-01-01
        • 2013-02-02
        • 1970-01-01
        • 2019-09-24
        • 2020-10-30
        相关资源
        最近更新 更多