Reputation: 49
For example http://jsfiddle.net/skpfknxo/
It removes the div #test
along with its children #test2
and #test3
.
I want to remove #test
without removing its children.
How could this be done?
Upvotes: 2
Views: 114
Reputation: 15555
$( "button" ).click(function() {
$( "#test2" ).unwrap();
});
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.
Upvotes: 6