JSFiddle - React, Tailwind, and code Playground
HTML
<div id="text">
<p style="color:red"> paragraph </p>
<div style="color:red"> div which should be stripped
<p style="color:red"> paragraph </p></div>
<strong style="color:red"> strong which should be stripped </strong>
</div>
JavaScript
$("#text *").not("p").each(function() {
var content = $(this).contents();
$(this).replaceWith(content);
});