[英]jquery, how to avoid hide menu when i click on it
I am trying to do the following code which works fine: 我试图做下面的代码工作正常:
/*
** SHOW OR HIDE A MENU DEPENDING IF I CLICK OUTSIDE OR INSIDE
*/
function showBasket(){
var $basket=$('#basket');
var nstyle=$basket.css("display");
if (nstyle=='none'){
$basket.fadeIn(false,function(){//showing the basket
$('html').bind("click",function(){
$basket.fadeOut();//hidding the basket
$("html").unbind("click");
});
});
}
}
Is there possible to avoid that the layer 'basket' doesn't hide when i click on it? 是否可以避免单击“隐藏”图层时隐藏它? My problem is that when i click in the html documen,t it hides, and i want that, but i also dont want to include the layer 'basket' in that event, because i have controls to use in the layer. 我的问题是,当我单击html documen时,它隐藏了,我想要那个,但是我也不想在该事件中包括图层“ basket”,因为我可以在图层中使用控件。
I would appreciate any help or idea, thank you in advance!! 我将不胜感激任何帮助或想法,在此先感谢您!!
try this 尝试这个
function showBasket(){
var $basket=$('#basket');
var nstyle=$basket.css("display");
$basket.on('click',function(e){
e.stopPropagation();
return false;
}
if (nstyle=='none'){
$basket.fadeIn(false,function(){//showing the basket
$('html').bind("click",function(){
$basket.fadeOut();//hidding the basket
$("html").unbind("click");
});
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.