JSFiddle - React, Tailwind, and code Playground

HTML

<div id="thediv">test</div>

CSS

div {
 width:200px;
 height:200px;
 background-color:#f00; 
    
}

JavaScript

$("#thediv").show(0, function() {
    var that = $(this);
    $(document).bind("click", function(e) {
        if($(e.target).attr("id") != that.attr("id")) {
           that.hide();
           $(this).unbind("click");
        }
    });
});