document.addEventListener('mouseup', function(e) { let container = document.getElementById('container'); if (!container.contains(e.target)) { container.style.display = 'none'; } });