JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div1">
<div id="div2">
blah blah
</div>
</div>
JavaScript
jQuery.fn.justtext = function() {
return $(this).clone()
.children()
.remove()
.end()
.text();
};
jQuery.fn.justtextinner = function() {
return $(this).clone()
.children()
.end()
.text();
};
alert($('#div1').justtextinner());