Phill Pafford Phill Pafford - 4 months ago 18
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

Have you tried the following:

$('#theDiv').prepend('<img id="theImg" src="theImg.png" />')
Comments