JSFiddle - React, Tailwind, and code Playground

HTML

<div id='myDiv'>
    This is the semi-inner text
    <div id='other'></div>
    This is the semi-inner text
<div>

JavaScript

$('#myDiv').contents().filter(function() {
    return this.nodeType == 3
}).each(function() {
    this.data = this.data.replace(/This is the semi-inner text/g, 'swapped');
});