JSFiddle - React, Tailwind, and code Playground

HTML

<div>test</div>
<a>test Anchor</a>
<div class='containers'>test NO CLICK</div>
<a>test Anchor</a>
<div class='containers'><span>test NO CLICK - </span>testDIV NO CLICK</div>
<a>test Anchor</a>

JavaScript

$('body *').filter(function(){
    return $(this).closest('.containers').length === 0; 
}).on('click', function(){
     alert('something on body was clicked that wasn\'t "element" or inside element');
});