function Menu(options) { var elem = options.elem; elem.onmousedown = function() { return false; } elem.onclick = function(event) { if (event.target.closest('.title')) { elem.classList.toggle('open'); } }; }