1
I have the following code:
$('#abre-busca').click(function(event){
event.preventDefault();
$('#menu-principal-sub li').css({'opacity':0});
setTimeout(function(){
$('#menu-principal-sub li').css({'display':'none'});
$('#menu-principal-sub form').css({'display':'inline-block'});
setTimeout(function(){
$('#menu-principal-sub form').css({'opacity':1});
},100);
},500);
});
$(document).click(function(event){
if($(event.target) != $('#barra-busca')){
$('#menu-principal-sub form').css({'opacity':0});
setTimeout(function(){
$('#menu-principal-sub form').css({'display':'none'});
$('#menu-principal-sub li').css({'display':'inline-block'});
setTimeout(function(){
$('#menu-principal-sub li').css({'opacity':1});
},100);
},500);
}else{
}
});
I want you to click out of #barra-busca
, the same closes and gives space to the other elements that will be shown, however, it occurs that when clicking outside it, nothing happens, and when clicking on it, or on the elements inside it, it executes the action of hiding and showing the other elements.
How can I correct ?
FIDDLE
https://jsfiddle.net/g0am9rvs/
WEBSITE LINK
You can create a Fiddle to make it easier to play?
– BrTkCa