JSFiddle - React, Tailwind, and code Playground
http://stackoverflow.com/questions/11867778/jquery-selecting-text-in-parent-div
by lalatino
HTML
<div class ="parent">
<div class="inner">Hello
<div>Goodbye</div>
World
</div>
</div>
JavaScript
$('.inner').each(function() {
var node = this.childNodes[0];
var text = '';
while (node) {
if (node.nodeType == 3) {
text += node.nodeValue; //append textNode's text
break; //only the 1st textNode - optional
}
node = node.nextSibling;
}
text = text.replace(/^\s+|\s+$/g, ''); //trim - optional
alert(text);
//console.log(text);
});