Note that there are some explanatory texts on larger screens.

plurals
  1. POAttempting to Set Text of SPAN element on asp.net page from JavaScript using JQuery
    text
    copied!<p>I am attempting to set text in a SPAN element from JavaScript and it is not working. Any help would be greatly appreciated.</p> <p>The HTML on the asp.net page is as follows:</p> <pre><code>&lt;div class="TimerRowDetail TimerDaysDetail"&gt; &lt;asp:Label ID="lblDays" runat="server" Text="yyy" ClientIDMode="Static"&gt;&lt;/asp:Label&gt; &lt;/div&gt; </code></pre> <p>The generated HTML is as follows:</p> <pre><code>&lt;div class="TimerRowDetail TimerDaysDetail"&gt; &lt;span id="lblDays"&gt;yyy&lt;/span&gt; &lt;/div&gt; </code></pre> <p>My JavaScript is as follows:</p> <pre><code>var lblDays = $("#&lt;%=lblDays.ClientID%&gt;"); if (lblDays != null) { alert("OK"); lblDays.innerHTML = "XXX"; } </code></pre> <p>I see the OK alert but the text never changes to XXX.</p> <p>I am testing with both IE 9 and FireFox 9.0.1.</p> <p>Thanks. <strong>EDIT:</strong> </p> <p>Ok, I am not suggesting the answer icarus gave is incorrect, only that it is not working in my environment.</p> <p>Below is the source for the page including the script I am using. It does not work on my machine.</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DatePlay.aspx.cs" Inherits="CountDownClock.WebUI.DatePlay" %&gt; &lt;!DOCTYPE html &gt; &lt;html lang="en"&gt; &lt;head runat="server"&gt; &lt;script src="Scripts/jquery-1.4.1.js" type="text/javascript"&gt;&lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"&gt; var lblDays = $("#&lt;%=lblDays.ClientID%&gt;"); lblDays.html("XXX"); alert("done"); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:Label ID="lblDays" runat="server" Text="yyy" ClientIDMode="Static"&gt;&lt;/asp:Label&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Again I am using IE 9 and FireFox on a Windows 7 box with HTML5 specified in the <p>Any suggestions would really be appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload