Jquery unwrap () method?
There wrap()
is a nifty method in jquery named that will wrap the selected element inside a new element, e.g .:
Start with:
<p>I wish I was wrapped!</p>
Add code:
$("p").wrap("<div></div>");
End with:
<div><p>I wish I was wrapped!</p></div>
But I need something that unfolds so that the above process will be canceled. It looks like the problem is that when you select a bad item (say, an unnecessary table), it always grabs what's inside it, so if I want to delete all <td>
s, I left nothing, because that was deleted td
and that- then inside.
Is there a standard reliable way to remove items, but only keep children / ancestors?
source to share
A quick Google search reveals that such functionality exists in the form of a small 576 byte plugin called jqueryunwrap . I haven't tried it personally, but it's worth it.;)
source to share