efnet-news/public/js/menu.js

14 lines
386 B
JavaScript
Raw Permalink Normal View History

2023-08-15 03:46:29 +00:00
const toggle = document.getElementById('toggle');
const menu = document.getElementById('menu');
function toggleMenu() {
menu.classList.toggle('main-nav__list--active');
this.classList.toggle('main-nav__btn--active');
this.setAttribute(
'aria-expanded',
this.getAttribute('aria-expanded') === 'true' ? 'false' : 'true'
);
}
toggle.addEventListener('click', toggleMenu, false);