This method uses jqueries contents().unwrap().
After a given timeout scan through all the contents unwrapping tags that don't have the class that you set earlier. Note: This method does not remove self closing tags like
See an example below.
//find all children .find('*') and add the class .within .addClass("within") to all tags
$('#answer_text').find('*').each(function () {
$(this).addClass("within");
});
setTimeout(function() {
$('#answer_text').find('*').each(function () {
//if the current child does not have the specified class unwrap its contents
$(this).not(".within").contents().unwrap();
});
}, 0);