我正在使用jQuery UI菜单作为上下文菜单,因此当用户单击表格中的单元格时,它将显示相关选项。问题是,它并不是真的被设计成像这样使用,所以当用户在菜单外单击时它不会隐藏。当用户单击外部时隐藏jQuery UI菜单
我尝试使用模糊方法:
$("#menu").menu({
blur: function(event, ui) {
$("#menu").css('top', '-1000px');
$("#menu").css('left', '-1000px');
}
});
出于某种原因,虽然,菜单隐藏,即使您滚动到菜单中的选项之一。
有没有简单的解决方案呢?
编辑: 拉起我使用菜单:
$("table.adminScheduleViewer tr td:nth-child(4), table.adminScheduleViewer tr td:nth-child(5), table.adminScheduleViewer tr td:nth-child(6), table.adminScheduleViewer tr td:nth-child(7), table.adminScheduleViewer tr td:nth-child(8), table.adminScheduleViewer tr td:nth-child(9), table.adminScheduleViewer tr td:nth-child(10)").click(function(event){
$("#menu").css('top', event.pageY);
$("#menu").css('left', event.pageX);
});
似乎总是先被称为如果我尝试使用$(“身体”)点击()来隐藏它。你可以改变命令jQuery处理点击?
http://stackoverflow.com/questions/2868582/click-outside-menu-to-close-in-jquery的副本? – 2015-05-05 17:30:34