How to hide a jquery ui menu when clicked anywhere else?
You want to use the blur event, which fires when an object loses focus. Clicking on something else will take the focus away.
$("#menu").blur(function () {
// Your code here to either hide the menu (.toggle())
// or remove it completely (.remove()).
});