tags:

views:

125

answers:

4

Hi, I want to put em tag before IMG tag dynamically , the image class is .photo.

<img class="photo" src="image.jpg" />

I want to convert this to

<em></em><img class="photo" src="image.jpg" />

using jQuery, I am using the append but its add the em in the img tag,

thanks.

+1  A: 

You can use the before() method.

kgiannakakis
+1  A: 

You need to use before()

FractalizeR
+2  A: 
$("img.photo").before("<em>");
bigmattyh
A: 
jQuery("img").before("em")

EDIT: Okay, no need to add the closing tag.

moxn