Hey there! I am facing an issue in my JS code. I wrote this code because I want the menu to close when a visitor clicks on another div (not the menu) if it is open. The code seems to be working fine in developer tools on Chrome or Firefox, but it's not working on mobile phones.
<script>
window.addEventListener('mouseup', function(event){
var box = document.getElementById('narvbar_menu');
if (event.target != box && event.target.parentNode != box){
box.style.display="none";
document.getElementById("close_menu").style.display="none";
}
});
</script>
Thanks for your help!