JSFiddle - React, Tailwind, and code Playground

HTML

<div id="parent">
    <span class="the_button">Hello World</span>
</div>

JavaScript

$(function() {
    var $button = $(".the_button");
    alert (isStale($button));
    $('#parent').remove();
    alert (isStale($button));
});
    
function isStale($elem) {
    return $elem.parents('body').length > 0;
};