JSFiddle - React, Tailwind, and code Playground

HTML

<h1>Title text <span>---inner text---</span> other text</h1>

CSS

span{
    
    color:red;
}

JavaScript

console.log($('h1').contents().nodeValue = 'New text');