lipenco lipenco - 7 months ago 8
Javascript Question

how can I remove wrapper (parent) without removing the child

I would like to remove parent without removing the child - is this possible?
html structure:

<div class="wrapper">
<img src"">
</div>
<div class="button">Remove wrapper</div>


After clicking on button I would like to have :

<img src"">
<div class="button">Remove wrppper</div>

Answer

Could use this API: http://api.jquery.com/unwrap/

Demo http://jsfiddle.net/7GrbM/

.unwrap

Code will look something on these lines:

Sample Code

$('.button').click(function(){
    $('.wrapper img').unwrap();
});
Comments