JSFiddle - React, Tailwind, and code Playground
HTML
<div class="example" class="test">
hallo
<div></div>
<p class="test">hi</p>
<div>
<b class="test">hi there</b>
</div>
</div>
JavaScript
$(document).ready(function () {
$('.example')
.contents()
.filter(function () {
return this.nodeType === 3; //Node.TEXT_NODE
}).remove();
});