Obviously a syntax error on my part.
I've got a large quantity of divs where a small amount of them have content wrapped in an anchor. what I'm trying to do is remove the anchors.
thanks for your help!
http://jsfiddle.net/danielredwood/rg6n6/
Desired HTML:
<div class="box"><a href="#"><img src="#"></a></div>
// becomes:
<div class="box"><img src="#"></div>
JavaScript:
$('.box img').unwrap('<a>');
Is this what you're looking for?
$('.box a img').unwrap()
.unwrap() has no arguments, it simply removes the parent tag of the matched selector. So by selecting the img tag directly under the a, you liberate it from its anchor, as you wanted.
Try:
$('button').click(function(){
$('.box a').contents().unwrap();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With