JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div_to_change">
This is the text
<br>
to be changed
<div id="div_that_shouldnt_change">
text that should not change
</div>
<div id="div_that_shouldnt_change2">
text that should not change
</div>
</div>
JavaScript
$("div").contents().filter(function(){ return this.nodeType == 3; }).first().replaceWith("changed text");