JSFiddle - React, Tailwind, and code Playground
HTML
<a href="javascript:void(0);" id="one">
Div One
</a>
<div id="two">
Div Two
</div>
CSS
#two {
display: none;
width: 100px;
height: 100px;
background-color: #AAA;
position: absolute;
top: 50px;
left: 50px;
}
JavaScript
$(document).ready(function(){
$("#two").click(function(e){
e.stopPropagation();
});
$("#one").click(function(e){
e.stopPropagation();
$(this).hide();
$("#two").show();
$(document).on("click", function(e){
$("#one").show();
$("#two").hide();
$(document).off("click");
});
});
});