[ad_1]
$(function() {
$('#loginBtn, #loginArea').on('click', function(e) {
$('#loginArea').show();
e.stopPropagation();
});
$('body').on('click', function() {
$('#loginArea').hide();
});
});
If the click is within the login area or on the button, then the event will not make it to the second handler to hide the login area.
[ad_2]
solved Click outside of div and more [duplicate]