JSFiddle - React, Tailwind, and code Playground
HTML
<h2 id="nameUser" >Muhammed <span> mobile :989 531 9991</span></h2>
JavaScript
$('#nameUser').contents().each(function() {
if (this.nodeType == 3)
this.data = "foo";
});
<h2 id="nameUser" >Muhammed <span> mobile :989 531 9991</span></h2>
$('#nameUser').contents().each(function() {
if (this.nodeType == 3)
this.data = "foo";
});