Thank you all! I tried
if( $('#lblAvailableQuantity').length ) and it is returning false, even though the control is present as span in the html produced. Can you please help - why $('#lblAvailableQuantity').length would return false?
I am invoking a jquery function on OnClientClick event of an imagebutton control and trying to find out the text of lblAvailableQuantity' inside this function, but haven't been able to so far..
<td><asp:ImageButton ID="imgPicColor" CssClass="imgPicColor" AlternateText='<%# DataBinder.Eval(Container.DataItem, "ColorID") %>' OnClientClick="ColorSwitch(); return false;" ImageUrl='<%# FormatURLColor(DataBinder.Eval(Container.DataItem, "ColorID"), DataBinder.Eval(Container.DataItem, "MerchandiseItemId")).ToString() %>' runat="server" Width="50" BorderStyle="None" /></td>
<
td align="left" valign="middle"><asp:Label runat="server" ID="lblAvailableQuantity" Visible="true" CssClass="lblTextAQ" Text="00" ></asp:Label></td>
function ColorSwitch() {
$(
'.imgPicColor').click(function(event) {
var colorID = $(this).attr('alt');
if ($('#lblAvailableQuantity').length) // this returns false
{
var test = $('#lblAvailableQuantity');
alert(test.text());
}