JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <div id="alert">Hello</div>
</body>

CSS

#alert {
    width: 200px;
    height: 200px;
    background-color: #EEE;
    display: block;
    padding: 10px;
}

JavaScript

$(document).on('mouseup', function (e)
{
    var alert = $('#alert');

     // Make sure neither the alert, 
     // nor anything inside of it was clicked

    if (!alert.is(e.target)
        && alert.has(e.target).length === 0)
    {
        alert.hide();
    }
});