The unwrap method
The unwrap method performs the inverse operation of the wrap method.
Syntax
So we will use the method:
.unwrap();
You can also pass an optional parameter to the method as a string, as a selector; if the element's parent does not match the specified selector, the method will not be applied to it:
.unwrap(selector);
Example
Let's do unwrap on all paragraphs with class www:
<div><p class="www">text</p></div>
<div><p class="www">text</p></div>
<div><p class="www">text</p></div>
<div><p>text</p></div>
$('.www').unwrap();
HTML the code will look like this:
<p class="www">text</p>
<p class="www">text</p>
<p class="www">text</p>
<div><p>text</p></div>
See also
-
methods
wrap,wrapAll⁅/ c⁆, ⁅c href="/en/javascript/lib/jquery/manual/wrapInner/"⁆wrappInner,
allowing you to work with wrapping elements