My position is like this
<p><img src="/media/118711/banner.jpg" width="344" height="113" alt="Banner"></p>
I want to remove the p tag using jquery, but I do not need to delete the content (image). Can anybody help me?
That should do it ...
$('p > *').unwrap();
jsFiddle .
The $('p > *') selector only works when the contents of p is another tag. If it contains only text, this selector did not hit it. This works for me:
$('p > *')
p
$("p").each(function() { $(this).replaceWith($(this).html()); });