My situation is like this
<p><img src="/media/118711/banner.jpg" width="344" height="113" alt="Banner"></p>
I want to delete the p tag using jquery but I do not need to delete content(image). Any one please can help me?
This should do it...
$('p > *').unwrap();
jsFiddle.
Selector $('p > *')
works only when content of p
is another tag. If it contains only text, then this selector doesn't hit it. This works for me:
$("p").each(function() {
$(this).replaceWith($(this).html());
});
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