I want to show a box when a button is clicked and hide it when I click out of the box.
The code I did works in Chrome and IE, but it doesn't in Firefox (I tested only in these three browsers). Firefox console shows me ReferenceError: event is not defined
.
$('.button.open_login .bb')
is the button.$('.button.open_login .panel_opened')
is the panel.
Code:
$(document).click(function(){
if(!$(event.target).closest('.button.open_login .panel_opened').length) {
if (site.ui.other.loginbox.is(":visible")){
site.ui.other.loginbox.fadeOut(150);
}
else {
if ($(event.target).closest('.button.open_login .bb').length){
site.ui.other.loginbox.fadeIn(150);
}
}
}
});
Thank you