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.
In JQuery
to set:
$("#LblCt").text("new text");
to get:
var text = $("#LblCt").text();
In Asp.Net
Thanks GOD, i don't use ASP...
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();
$("#LblCt).text()=""
This assumes that the id is #LblCt
. In ASP.NET that would be the server side ID, you want the client side Id.
Try
$("#<%= LblCt.ClientId %>").text();
even though this is ages ago, i think what you can also do is set your object id to be static using ClientIDMode="Static". <asp:Label ClientIDMode="Static" ID="LblCt" runat="server" Style="display:none" Text="">72</asp:Label>
Unfortunately i still have to use
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.