hide menu to click on outside jquery codepen code example
Example: Click Outside Close Menu Box
window.addEventListener('mouseup', function(event){
var box = document.getElementById('box1');
if (event.target != box && event.target.parentNode != box){
box.style.display = 'none';
}
});