JSFiddle - React, Tailwind, and code Playground

HTML

<div id="div">
    div
    <span>child</span>
</div>

CSS

#div {
    color: white;
    background-color: brown;
}

body {
    height: 1000px;
}

JavaScript

$(function() {
    var div = $("#div");
    $("body").on("click", function (e) {
        if (div.has(e.target).length || e.target == div[0])
            return;
        
        alert("VocĂŞ clicou fora da div!");
    });
})