[SOLVED] Get text value from element when display:none

Issue

Html code:

<asp:Label ID="LblCt" runat="server" Style="display:none" Text="">72</asp:Label>

I get "" when I use with this codes:
JQuery: $("#LblCt).text(), $("#LblCt).textContent
Asp.Net: LblCt.Text

How can I get the text of the label?

I can’t use CSS – visibility:hidden

Update:
The problem is because of display:none, when Display:block there is no problem.

Solution

You seem to have invalid markup…

<asp:Label ID="LblCt" runat="server" Style="display:none" Text="">72</asp:Label>

should be:

<asp:Label ID="LblCt" runat="server" Style="display:none" Text="72"></asp:Label>

then to get the value with JQuery, you can do this.

$("#<%= LblCt.ClientId %>").val();

Answered By – bastos.sergio

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *