JSFiddle - React, Tailwind, and code Playground

HTML

<span> hello this is test <span class="button">click here</span></span>

JavaScript

$(document).ready(function(){
    $('.button').on('click', function(){
        var parentElement = $(this).parent().clone();
        parentElement.children('span').remove()
        alert(parentElement.text());
    });

});