问题:
I have some HTML menus, which I show completely when a user clicks on the head of these menus. 我有一些HTML菜单,当用户单击这些菜单的标题时,它们会完整显示。 I would like to hide these elements when the user clicks outside the menus' area. 当用户在菜单区域之外单击时,我想隐藏这些元素。
Is something like this possible with jQuery? jQuery可能会发生这种情况吗?
$("#menuscontainer").clickOutsideThisElement(function() {
// Hide the menus
});
解决方案:
参考一: https://stackoom.com/question/dnL/如何检测元素外部的点击参考二: https://oldbug.net/q/dnL/How-do-I-detect-a-click-outside-an-element
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4297464