Here is the code...
<div id="box"></div>
<script type="text/javascript">
(function () {
var isFocus = false;
$('#box').on('mouseenter', function () {
isFocus = true;
}).on('mouseleave', function () {
isFocus = false;
});
$(document).click(function () {
if (!isFocus) $('#box').hide();
});
})();
</script>