Source : How to remove only the parent element and not its child elements in jQuery?
1 2 |
var cnt = jQuery(".remove-just-this").contents(); jQuery(".remove-just-this").replaceWith(cnt); |
Code source avant manipulation du DOM :
1 2 3 4 5 6 7 8 9 |
<div> some text <div class="remove-just-this"> <p>foo</p> <p>bar</p> some text node here </div> some text </div> |
Code source après manipulation du DOM :
1 2 3 4 5 6 7 |
<div> some text <p>foo</p> <p>bar</p> some text node here some text </div> |