The unwrap method

The unwrap method performs the inverse operation of the wrap method.

Syntax

So we will use the method:

javascript.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:

javascript.unwrap(selector);

Example

Let's do unwrap on all paragraphs with class www:

html<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>
javascript$('.www').unwrap();

HTML the code will look like this:

html<p class="www">text</p>
<p class="www">text</p>
<p class="www">text</p>
<div><p>text</p></div>

See also