George
George

Reputation: 2110

Jquery dynamic link removal

Consider the following

var newLink = $('<a/>').attr('href', name);
previewImage.wrap(newLink);

It outputs

<a href><img src=" "/></a>

I need some Jquery code to modify this to: <img src=" "/> (Only remove the wrapping link without the img). Any help will be greatly appreciated.

Upvotes: 1

Views: 142

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1074268

Use unwrap:

theImage.unwrap();

E.g.:

newLink.find("img").unwrap();

Upvotes: 1

Related Questions