JSFiddle - React, Tailwind, and code Playground

HTML

<div id="theDiv">Some contents</div>
<div id="showDivBtn">Toggle link</div>

CSS

#theDiv {
    width: 50px;
    height: 50px;
    background: #e9e9e9;
}
#showDivBtn {
    margin-top:100px;
    width: 100px;
    height: 50px;
    cursor: pointer;
}
}

JavaScript

$('#theDiv').hide();

$(document).on('click', function(e) {
    if ( $(e.target).closest('#showDivBtn').length ) {
        $("#theDiv").show();
    }else if ( ! $(e.target).closest('#theDiv').length ) {
        $('#theDiv').hide();
    }
});