jQuery unwrap() – Remove wrapping div

disable jQuery animations

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>

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

You may like:  Tips and Tricks for powerful developers

Leave a Reply

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