JSFiddle - React, Tailwind, and code Playground
HTML
<a>click</a>
<div class="drop user-menu">user menu asd</div>
CSS
.drop {
display:none;
background:blue;
}
a {
background:black;
color:white;
}
JavaScript
$('a').on('click', function (e) {
e.stopPropagation();
$('.drop.user-menu').fadeIn();
});
$('.drop.user-menu').on('click', function (e) {
e.stopPropagation();
$('.drop.user-menu').fadeIn();
});
$(document).on('click', function (e) {
if (e.target != $('.drop.user-menu')) {
$('.drop.user-menu').fadeOut();
}
});