i want to adding class .open using toggle in .nav after click #menu-icon, the class ‘open’ is appear in the inspect element after i click the #menu-icon, but the .nav is not showing any style in .open. Why should i do?
ps : i used bootstrap to make the nav
HTML
<!-- logo -->
<div class="logo">
<img src="assets/logo.png" alt="logo g's shop">
</div>
<i class="ri-menu-line" id="menu-icon"></i>
<!-- nav -->
<ul class="nav nav-pills nav-fill m4">
<li class="nav-item">
<a class="nav-link active .bg-white" aria-current="page" href="#">ALL ITEM</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">SMARTPHONES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">LAPTOPS</a>
</li>
</ul>
CSS
.nav {
position: absolute;
z-index: 10001;
top: 65px;
right: 30px;
width: 270px;
background-color: #f3efef;
display: flex;
flex-direction: column;
justify-content: flex-start;
border-radius: 4px;
transition: all .50s ease;
font-size: 14px;
}
.nav-item {
margin-top: -2px;
border-radius: 4px;
}
#menu-icon {
display: block;
}
.nav .open {
left: 0;
}
JS
let menu = document.querySelector('#menu-icon');
let navbar = document.querySelector('.nav');
menu.addEventListener("click", function() {
navbar.classList.toggle('open');
});
i expect that the “.nav .open” is working a.k.a “.nav” is dissapear (become left: 0;) after i click the #menu-icon, better using jquery instead of vanilla js