Abs Abs - 2 months ago 14
Javascript Question

Remove parent but keep children using jQuery

I would like to remove the parent and keep the children in my HTML using jQuery. This works:


However, it removes the text and comment node types - how can I amend this so that I keep the text?

Happy to do this with pure Javascript too.


As @Cᴏʀʏ says, unwrap() should help you acheive this.

Alternatively, you could do something like this: