I am working on the following jQuery code. Assuming I have the following HTML code sample:
<div class="my-class"> 
   <h1>Hello</h1>
</div>
With jQuery, I need add the following <img src="smiley.gif" alt="Smiley face" height="42" width="42"> immediately after the opening div my-class tag. I need to target the my-class class selector.
What I am trying to achieve is the following:
<div class="my-class">
   <img src="smiley.gif" alt="Smiley face" height="42" width="42">
   <h1>Hello</h1>
</div>
I have tried the following:
$('div.my-class').after('<img src="smiley.gif" alt="Smiley face" height="42" width="42">');
but this inserts it after the closing div tag, which is not what I am after.
 
     
     
    