JSFiddle - React, Tailwind, and code Playground

HTML

<div class="test">Text1<span> nice</span></div>

JavaScript

$($('.test').contents()[0]).replaceWith('New Text');