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

Recover From Google Penalties in 10 Steps in 2024

Facing Google penalties can be a daunting challenge for businesses relying on organic search traffic.…

14 hours ago

What is the Future of Artificial Intelligence?

Technology, undeniably, has made our lives easier. But the advent of artificial intelligence has been…

17 hours ago

Role of guest post services in SEO

Guest post services have become an essential tool for businesses and individuals looking to increase…

1 day ago

Top Programming Trends You Need to Know in 2024

Programming continues to evolve at a rapid pace, with new trends and technologies emerging every…

1 day ago

Why startups need a digital marketing strategy?

Let’s be honest; a startup business hardly has sufficient amount to promote their services and…

2 days ago

How to Find the Best SEO Consultant in Toronto to Boost Your Rankings

Introduction In today's digital age, having a strong online presence is crucial for businesses in…

2 days ago