skrudjmakdak,
<!DOCTYPE HTML>
<html>
<head> </head>
<body>
<input id="test" type="text">
<div id="menu" style="border: 1px solid #555; display: none; height: 100px; width: 170px"></div>
<script>
var menuIsHide = true;
test.onblur = function() {
menu.style.display = 'none';
menuIsHide = true;
};
window.addEventListener('click', function(e) {
var self = e.target;
if(self.id == 'test' == menuIsHide) {
menu.style.display = menuIsHide ? 'block' : 'none';
menuIsHide = !menuIsHide;
}
});
</script>
</body>
</html>