Phill Pafford Phill Pafford - 1 year ago 153
Javascript Question

jQuery add image inside of div tag

I have a div tag

<div id="theDiv">Where is the image?</div>

I would like to add an image tag inside of the div

End result:

<div id="theDiv"><img id="theImg" src="theImg.png" />Where is the image?</div>

Answer Source

Have you tried the following:

$('#theDiv').prepend('<img id="theImg" src="theImg.png" />')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download