SyntaxFix
Write A Post
Hire A Developer
Questions
If using a plugin is ok in you case, then I suggest Ben Alman's clickoutside plugin located here:
its usage is as simple as this:
$('#menu').bind('clickoutside', function (event) { $(this).hide(); });
hope this helps.