jQuery unwrap() – Remove wrapping div

jQuery Notification plugin

The unwrap() method remove the parents of the selected elements from the DOM and leave the matched elements in their place.

.unwrap() method does not accept any arguments.

Example of jQuery unwrap:

You have the following HTML:

<div class="main">
<div class="wrap"><div class="sub">John Doe</div></div>
<div class="wrap"><div class="sub">Jane Doe</div></div>
</div>

Using .unwrap() method you can remove wrapping div with class “sub”.

$(".sub").unwrap();

Result will be:

<div class="main">
<div class="sub">John Doe</div>
<div class="sub">Jane Doe</div>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *