Hello, I would like to know how to make this responsive menu that not only clicks on the hamburger to make toggle (which is already done) but click outside on any part of the document to removeClass, I tried to use $ ("* not: .hamburgesa "). removeClass inside the if when you already have that class, to remove it when I click anywhere except on the menu itself, but it does not work out. thanks
$(document).ready(function(){
$('.hamburgesa').on('click', function(){
$('nav').toggleClass('apareceMenu');
if ( $('nav').hasClass('apareceMenu') ) {
// a rellenar
}
});
});
.hamburgesa {
position: fixed;
top: -6px;
right: 10px;
cursor: pointer;
color: black;
font-size: 3em;
text-shadow: 0 0 10px white;
z-index: 9999;
}
nav{
width: 250px;
height: 100vh;
border-right: 1px solid #999;
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
nav.apareceMenu{
-webkit-transform: translateX(0);
-ms-transform: translateX(0);
transform: translateX(0);
}
nav ul{
float: none;
}
nav li{
display: block;
text-align: left;
}
nav a {
line-height: 14vh;
font-size: 11px;
font-weight: 600;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>responsive menu</title>
</head>
<body>
<span class="hamburgesa">≡</span>
<nav>
<ul>
<li><a href="#hero" class="menu" data-id="#hero">Inicio</a></li>
<li><a href="#nosotros" class="menu" data-id="#nosotros">Nosotros</a></li>
<li><a href="#productos" class="menu" data-id="#productos">Productos</a></li>
<li><a href="#calidad" class="menu" data-id="#calidad">Calidad</a></li>
<li><a href="#logistica" class="menu" data-id="#logistica">Logística</a></li>
<li><a href="#environment" class="menu" data-id="#environment">Medio ambiente</a></li>
<li><a href="#contacto" class="menu" data-id="#contacto">Contacto</a></li>
</ul>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>