This is a bad idea.
Writing $('*') will add your click handler to every single element in the document, which will be slow. In addition, it won't handle clicks on any new elements added later. (Unless they bubble up)
Instead, you should handle the click event for the root element, like this:
$(document).click(function(e) {
if (e.target === menu || $(e.target).parents().is(menu))
return;
$(menu).hide();
});
All click events on any element will eventually bubble up to the root element (unless you cancel it), so this will handle every single click.