JSFiddle - React, Tailwind, and code Playground

by arunberti

HTML

<div id="login">
...
</div>

CSS

#login {
background-color:red;
position:absolute;
width:413px;
height:190px;
z-index:110;
left:189px;
top:43px;
overflow:visible;
line-height:normal;
}

JavaScript

$(document).mouseup(function (e)
{
    var container = $("#login");

    if (!container.is(e.target) // if the target of the click isn't the container...
        && container.has(e.target).length === 0) // ... nor a descendant of the container
    {
        container.hide();
    }
});