JSFiddle - React, Tailwind, and code Playground

JavaScript

var temp='<div>Some text</div><p style="color:red">More text<span>here</span></p><p>Even more</p>';

var $temp=$("<span>" + temp + "</span>").find('span,p').contents().unwrap().end().end();

alert($temp.html());