I am trying to create a JavaScript function that will make my side navigation menu close when a user taps outside it. Here is the code that am trying to implement after fetching the navigation.
var sidenav = document.getElementById("Mynav");
window.onclick = function(event) {
if (event.target == sidenav) {
sidenav.style.display = "none";
}
};
The other sidenav functionalities are okay. But I suspect this equity JavaScript module (==), am not sure if it should be (!=). Any help will be great appreciated.