Categories: jQuery

jQuery unwrap() – Remove wrapping div

Share

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>

Recent Posts

Why Flexible Financing is the Future of Small Business

Small businesses are the backbone of the economy. Still, they often face daunting hurdles when…

1 hour ago

Warm Comfort: Choosing the Best Hot Water Bottle for Cozy Nights

Introduction: As the chill of winter settles in or a bout of cold weather strikes,…

19 hours ago

One Location, Different Perspectives: The Allure of Dubai Marina Apartments

Nestled along the glittering waterfront of the City of Gold, Dubai Marina beckons to discerning…

19 hours ago

How to launch a successful online dating app?

If you want to open a match-making dating app in the wide digital market and…

22 hours ago

Role Of Gojek Clone In Growth Campaigns For Your Business

When was the last time you heard that a clone app like Gojek could efficiently…

1 day ago

How to Optimize Your E-Commerce Pages and Improve UX?

The e-commerce market is growing and evolving at a rapid pace. More and more people…

1 day ago