JSFiddle - React, Tailwind, and code Playground
HTML
<div id="blah">
blah
<span>test</span>
<span>hello</span>
</div>
JavaScript
console.log('Only non-blank text nodes:');
$('#blah')
.contents()
.filter(function(){
return this.nodeType === 3 && $.trim(this.nodeValue) !== '';
}).each(function(){console.log($(this).context.data); });
console.log('All text nodes:');
$('#blah')
.contents()
.filter(function(){
return this.nodeType === 3;
}).each(function(){console.log($(this).context.data); });