I would like to remove the parent and keep the children in my HTML using jQuery. This works:
$('#my_span').children().insertBefore('#my_span').end().end().remove();
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: