0
I would like to be able to click the buttons on the menu to add the stylized class and return to the normal style on the previous button for example: when I click on the button 1 it is styled, then when I click on the button 2 it is styled and the button 1 loses the style.
The current code is as follows::
let menu = document.querySelectorAll('.menu-item');
menu.forEach((item) =>{
item.addEventListener('click', function(){
item.classList.add('menu-item-actived');
});
});
item.addeventlistener('click', Function(el)' item.classList.remove('menu-item-actived'); el.classList.add('menu-item-actived') }); Try this
– hugocsl
the easiest way would be to remove the style of all buttons and then add only to the button that should have the style
– Ricardo Pontual
Hello Ricardo all right? Could you tell me more about how to do this?
– Filipe Gomes
hugocsl Thanks for the tip, I’ll try!
– Filipe Gomes