JSFiddle - React, Tailwind, and code Playground

HTML

<span class='spanClass'>span text</span>
test this string....

JavaScript

jQuery.fn.justtext = function() {

    return $(this).clone()
            .children()
            .remove()
            .end()
            .text();

};


alert($('.spanClass').parent().justtext());