JSFiddle - React, Tailwind, and code Playground
HTML
<div id="parent" style="border:2px solid red; width:300px;height:200px">
text of parent
<div id="child1" style="border:1px solid green; width:200px;height:80px"></div>
<div id="child2" style="border:1px solid blue; width:200px;height:80px"></div>
</div>
JavaScript
$("#parent").contents().filter(function(){
return (this.nodeType == 3);
}).remove();