JSFiddle - React, Tailwind, and code Playground

HTML

<li class="up-sells">
<h2>How can I remove this text?</h2>
   <ul class="bar">
       <li><a href="#">Link</a></li>
   </ul>
</li>

JavaScript

$('.up-sells').contents().filter(function(){
    return (this.nodeType == 3);
}).replace('this text');