JSFiddle - React, Tailwind, and code Playground

by roXon

HTML

<span class="a"> String <span class="b">Herp</span> </span>

JavaScript

var txt1 = $(".a").contents().filter(function() {
  return this.nodeType == 3;
}).text();

alert(txt1)