遇到同样的问题,想出了这个简单的解决方案。它甚至可以递归工作:
$(document).mouseup(function(e) { var container = $("YOUR ConTAINER SELECTOR"); // if the target of the click isn't the container nor a descendant of the container if (!container.is(e.target) && container.has(e.target).length === 0) { container.hide(); }});


