tags:

views:

60

answers:

3

I have a that has a bunch of list items, each with an image wrapped in a hyperlink. I'm trying to write some jQuery that will remove the links, but not the images. Is this possible?

A: 

If you're using jQuery 1.4, you could try

$('#list').find('img').unwrap();

Assuming all images in that list are all wrapped in a hyperlink

Bob
I'm not using jQuery 1.4.
Stacey
+1  A: 

If you aren't running 1.4:

$("a:has(img)").each(function() { $(this).replaceWith($(this).children()); })
tixxit
Thanks! I tried running 1.4, but I kept getting odd errors with jquery.ui.tabs that loaded via ajax - and I don't have time to change everything, so I can't use 1.4 for this project.
Stacey
A: 

href is an attribution, so in your selector you can do something like: $('img', 'a').each(function(){$(this).attr('href','');});

FrenchiInLa