I would like to remove the 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 the button I would like to have:
<img src""> <div class="button">Remove wrapper</div>
Pure JS (ES2015) solution, in my opinion easier to read than jQuery-solutions.
node.replaceWith(...node.childNodes)
Node has to be an ElementNode
const wrapperNode = document.querySelector('h1') wrapperNode.replaceWith(...wrapperNode.childNodes)
<h1> <a>1</a> <b>2</b> <em>3</em> </h1>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With