Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove divs around a div [duplicate]

Tags:

jquery

My HTML

<div class="wrapper">
  <div class="wrapper2">
     <div class="real_content"></div>
  </div>
</div>

Question

Is there any way for me to remove the 2 divs around <div class="real_content"></div> so it won't appear on HTML and front end of my website? Thanks.

like image 963
nasty Avatar asked Mar 06 '26 06:03

nasty


1 Answers

You could try .replaceWith() (docs):

$('.wrapper').replaceWith( $('.real_content') );

There's also an .unwrap() function (docs), if you'd prefer a more relative way:

$('.real_content').unwrap().unwrap();
like image 200
Matt Stauffer Avatar answered Mar 08 '26 19:03

Matt Stauffer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!