the*_*rsh 13
小提琴链接:http://jsfiddle.net/eAGjM/
您需要检查点击的部分既不是Menu也不是它的子元素.如果您的菜单包含子元素,则需要进行此检查,否则单击子元素也会隐藏菜单.
$(document).mouseup(function(e){
var menu = $('selector');
if (!menu.is(e.target) // The target of the click isn't the container.
&& menu.has(e.target).length === 0) // Nor a child element of the container
{
menu.hide();
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3763 次 |
| 最近记录: |