JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo">
<span>
<a href="#" class="no-want">X</a>
1
</span>
<span>
<a href="#" class="no-want">X</a>
2
</span>
<span>
<a href="#" class="no-want">X</a>
Hello
</span>
</div>
<div id='result'>
</div>
CSS
#result {
border:1px solid blue;
}
JavaScript
var result = $("#foo span")
.contents()
.filter(function() {
return this.nodeType === 3;
}).map(function() {
return $(this).text().trim();
}).filter(function() {
return this != "";
}).toArray();
$("#result").text(result.join());