jquery 点击页面其他地方实现隐藏菜单功能

1、给页面文档添加一个点击事件函数,在函数内实现隐藏菜单功能。
$
('html').click(function(){//Hide the menus if visible});//用$(document)也可以
2、对于菜单本身不希望在点击它时将自己隐藏,需要为菜单本身的点击事件添加以下方法,用来阻止点击事件的传播。 //在所有不想触发页面点击事件的地方 阻止冒泡。 $('#menucontainer').click(function(event){event.stopPropagation();});



忘记哪里转的了 sorry
原文地址:https://www.cnblogs.com/mushishi/p/3193480.html