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

1、给页面文档添加一个点击事件函数,在函数内实现隐藏菜单功能。
$
('html').click(function(){//Hide the menus if visible}); 2、对于菜单本身不希望在点击它时将自己隐藏,需要为菜单本身的点击事件添加以下方法,用来阻止点击事件的传播。 $('#menucontainer').click(function(event){event.stopPropagation();});
参考资料:http://stackoverflow.com/questions/152975/how-to-detect-a-click-outside-an-element
原文地址:https://www.cnblogs.com/xuedong09/p/2913998.html