JSFiddle - React, Tailwind, and code Playground

by wirey00

HTML

<h2 id="nameUser">Muhammed<span> mobile :989 531 9991 </span>Ahmed</h2>

JavaScript

$('#nameUser').contents().filter(function() {
    return this.nodeName != 'SPAN';
}).each(function(i) {
    this.nodeValue = 'name'+i;
});