0
我有一个下拉菜单,我想要的行为,当点击菜单外,它关闭。如何关闭菜单时点击它
这是我的jQuery代码:
<script>
$(document).ready(function(){
$(".a-for-noti-scroll").on("click",function(){
$("#nano").toggleClass("x");
$(".top-triangle-noti-scroll").toggleClass("y");
e.stopPropagation();
});
$("body").on("click",function(e){
$('#nano').css('visibility', 'hidden');
$(".top-triangle-noti-scroll").css('display', 'none');
e.stopPropagation();
});
});
</script>
但是,这是行不通的。
我试着.hide()
为body
,但这样菜单不会打开。 我该怎么办?
尝试使用$(document).on(“click” – Scottie 2015-02-08 06:26:48
并确保添加'e'作为参数('...“单击”,函数(e){...')。 – JCOC611 2015-02-08 06:27:26
亲爱的朋友这不是工作,我添加文件,而不是工作,而是添加文件,而不是工作 – arezoo 2015-02-08 06:56:43