T
T
tosha732020-04-26 23:08:03
css
tosha73, 2020-04-26 23:08:03

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();
});


another style worked - wrapblur

2. How to hide another menu when one menu is called

$('#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');
};
});


Everything can be viewed at - https://newcsgosettings.at.ua/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arseny, 2020-04-26
Matytsyn @ArsenyMatytsyn

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 question

Ask a Question

731 491 924 answers to any question