How can I remove wrapper (parent element) without removing the child?

后端 未结 7 1236
天命终不由人
天命终不由人 2020-12-03 20:48

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

HTML structure:

7条回答
  •  温柔的废话
    2020-12-03 21:30

    Pure JS (ES6) solution, in my opinion easier to read than jQuery-solutions.

    function unwrap(node) {
        node.replaceWith(...node.childNodes);
    }
    

    node has to be an ElementNode

提交回复
热议问题