Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove previously set jQuery .wrapInner()?

Tags:

jquery

$('#main').wrapInner('<div></div>')

.wrap() you just remove with .unwrap()

.unwrapInner() seems to be not in the library.

.unwrap() not working with .wrapInner()

Somebody faced the same problem? Your help is very appreciated.

like image 894
Rafff Avatar asked Mar 16 '26 18:03

Rafff


1 Answers

First, you can put a marker class on your div elements (it probably won't matter, but just in case):

$("#main").wrapInner('<div class="wrapper"></div>'); // Notice class=wrapper

Then you can unwrap it using contents().unwrap():

$("#main > .wrapper").contents().unwrap();

Jsfiddle: http://jsfiddle.net/prankol57/wkvyzre6/

like image 90
soktinpk Avatar answered Mar 19 '26 07:03

soktinpk



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!