0
I can’t get when one menu opens the other to close. I tried the following code:
const itemLinks = document.querySelectorAll('.header-item')
const menus = document.querySelectorAll('.nav-menu')
for(let i = 0; i < itemLinks.length; i++){
itemLinks[i].addEventListener('click',mostrarMenu)
}
function mostrarMenu(e){
console.log(menus)
for(let i = 0; i < menus.length; i++){
}
}
<a href="#one" class="header-item header-item--one">menu one</a>
<a href="#two" class="header-item header-item--two">menu two</a>
<nav class="nav-menu">
<ul>
<li>Item Um</li>
<li>Item Dois</li>
<li>Item Três</li>
</ul>
</nav>
<nav class="nav-menu">
<ul>
<li>Item Um</li>
<li>Item Dois</li>
<li>Item Três</li>
</ul>
</nav>
Could you elaborate a [mcve] demonstrating the problem? Your code seems to be incomplete and quite confused as to what you want to do.
– Woss
good morningAnderson the code was really confusing hehe, had modified the html and forgot to edit the js.. more like this.. it remains incomplete n can go on already tried more I can only get that by clicking on a link open the menu and after clicking on another it opens at the same time. what I want to do is that when clicked on the other it closes,if you can help me thank hug.
– Geniton Lima
Have you tried using jQuery? It provides this type of pre-built functionality. Check out this https://www.w3schools.com/jquery/
– Laura Regina