I'd suggest using the stopPropagation() method as shown in the modified fiddle:
$('body').click(function() {
$(".popup").hide();
});
$('.popup').click(function(e) {
e.stopPropagation();
});
That way you can hide the popup when you click on the body, without having to add an extra if, and when you click on the popup, the eventβ¦
Top comments (0)