Refactoring menu.js
This commit is contained in:
parent
d6332eff74
commit
d0d945b784
1 changed files with 6 additions and 9 deletions
|
@ -2,13 +2,10 @@ var toggle = document.getElementById('toggle');
|
|||
var menu = document.getElementById('menu');
|
||||
|
||||
toggle.addEventListener('click', function () {
|
||||
if (menu.classList.contains('main-nav__list--active')) {
|
||||
this.setAttribute('aria-expanded', 'false');
|
||||
this.classList.remove('main-nav__btn--active');
|
||||
menu.classList.remove('main-nav__list--active');
|
||||
} else {
|
||||
menu.classList.add('main-nav__list--active');
|
||||
this.classList.add('main-nav__btn--active');
|
||||
this.setAttribute('aria-expanded', 'true');
|
||||
}
|
||||
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'
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue