Answer the question
In order to leave comments, you need to log in
Can't figure out how to close the menu by clicking on an empty field?
There were 2 problems:
1. I can't figure out how to cross the JS code
, namely, how to make it so that when I click on
$('#search').click(function(e){
var $s = $('#searchdiv');
if ($s.css('display') != 'block') {
$s.fadeIn(200);
var firstClick = true;
$(document).bind('click.myEvent',function(e){
if (!firstClick && $(e.target).closest('#searchdiv').length == 0) {
$s.fadeOut(200);
$(document).unbind('click.myEvent');
}
firstClick = false;
});
};
e.preventDefault();
});
$('#team').click(function(e2){
if($('#team-menudiv').css('display')=='block'){
$('#team-menudiv').fadeOut(200);
$('#wrapblur').fadeOut(200);
$('#wrap').removeClass('blur');
}else{
$('#functiondiv').fadeOut(200);
$('#team-menudiv').fadeIn(200);
$('#wrapblur').fadeIn(200);
};
});
$('#menu').click(function(e1){
if($('#menudiv').css('display')=='block'){
$('#menudiv').fadeOut(200);
$('#wrapblur').fadeOut(200);
$('#wrap').removeClass('blur');
}else{
$('#functiondiv').fadeOut(200);
$('#menudiv').fadeIn(200);
$('#wrapblur').fadeIn(200);
$('#wrap').addClass('blur');
};
});
Answer the question
In order to leave comments, you need to log in
Bind the click intercept to #wrapblur. By the way, don't use the ID on the page just for the sake of it.
Or use bubbling and event trapping.
Ah, I misread it.
You need to hide everything that should be hidden in each function, even if the element is not displayed. Or bind the check to a "global" trigger variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question