user1729506
user1729506

Reputation: 975

How to unwrap element using jQuery 1.3.2

<div class="photo">
 <a href="#"><img src="/media/image.jpg"></a>
</div>

Using unwrap() is awesome, but right now I have to unwrap the img above using an older version of jQuery, removing the link and retaining just the image inside of the div.

Upvotes: 1

Views: 226

Answers (3)

Arun P Johny
Arun P Johny

Reputation: 388316

If you want to place the contents along with the associated data/events etc then

$('.photo a').each(function(){
    $(this).after($(this).contents());
    $(this).remove()
})

Demo: Fiddle or this

Upvotes: 1

patel.milanb
patel.milanb

Reputation: 5990

$('.photo a').replaceWith($('.photo a').html());

Working Example: Jsfiddle

Upvotes: 1

Adil
Adil

Reputation: 148140

You can try setting html of div, also the closing / of img tag is missing.

Live Demo

$('.photo').html($('.photo a').html())

Upvotes: 4

Related Questions