0

I'm having a hard time searching for the answer to this, probably I'm using the wrong terminology. How do I have a child element replace its parent element (the parent element deleted completely and the child element taking the parent's place in the DOM.)

If I have the following code:

<div id="some-element">
  <div id="parent">
    <div id="child">
      <p>This is a paragraph.</p>
    </div>
  </div>
</div>

And my cursor is at the beginning of the element "child" (or alternatively I have selected the entire element), is there a command that would transform it to the following:

<div id="some-element">
  <div id="child">
    <p>This is a paragraph.</p>
  </div>
</div>

I perform a similar function frequently in paredit using paredit-raise-sexp, but this is my first time working in HTML and I can't find how to do it in web-mode. I feel like it's probably staring me in the face but I'm missing it.

  • So you want to remove the parent element, unwrapping it from the child. – Drew May 30 at 4:47
  • Yes, that's what I want to do. Thanks for giving me the right word, I think I may have found the solution now that I know what to ask for; I'm testing it now. – HarryFromMarydelDE May 30 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.