Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove div without inner elements

I would like to remove one div element, but without its children. For example, let's say that i have one div with id wrapper, and inside it 5 paragraphs.

I want to remove only the wrapper div, but to leave paragraphs alive. I have tried both remove() and detach(), but they both clean out the inner elements.

Any advice?

like image 340
fluxus Avatar asked Jun 28 '12 21:06

fluxus


1 Answers

http://api.jquery.com/unwrap/ should do it:

The .unwrap() method removes the element's parent. This is effectively the inverse of the .wrap() method. The matched elements (and their siblings, if any) replace their parents within the DOM structure...

like image 155
Uku Loskit Avatar answered Oct 03 '22 02:10

Uku Loskit