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

后端 未结 7 1225
天命终不由人
天命终不由人 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:42

    Surprised that nobody's posting the simplest answer:

    // Find your wrapper HTMLElement
    var wrapper = document.querySelector('.wrapper');
    
    // Replace the whole wrapper with its own contents
    wrapper.outerHTML = wrapper.innerHTML;
    
    0 讨论(0)
提交回复
热议问题