JSFiddle - React, Tailwind, and code Playground

by Ebram

HTML

<div id="parent">parent text
    <div id="child1">child1 text</div>
    <div id="child2">child2 text</div>
</div>

JavaScript

$('#parent').contents().filter(function () {
    return this.nodeType === 3;
}).remove();