tech74 tech74 - 5 months ago 11x
jQuery Question

JQuery change text of paragraph which contains image

I have the following html

<p id="logo400_120_spinner"><img src="/global/img/spinner.gif"></p>

I use jquery to try to set the text to Loading or removing depending on circumstance but I am just getting the text and losing the spinner image. I would like the spinner to be present with text on the right hand side

Here is the jquery I use


The spinner image disappears with the above.


Use .html() to change the inner HTML instead of just the plaintext so you can use an img tag

To show:

 $("#logo400_120_spinner").html('<img src="/global/img/spinner.gif">Loading');

To get rid of the loading text:

$("#logo400_120_spinner").html('<img src="/global/img/spinner.gif">');

Another option is just to put the "Loading" text into a span and just show and hide that span with JQuery.