showing results for - "js change hamburger 26 show menu"
Naelle
27 Apr 2016
1var menu = document.querySelector(".header__main-nav")
2var ham = document.querySelector(".header__burger-container")
3
4ham.addEventListener("click", toggleMenu)
5
6function toggleMenu() {
7  if (menu.classList.contains("header__main-nav--show")) {
8    menu.classList.remove("header__main-nav--show");
9    ham.classList.toggle("change");
10  } else {
11    menu.classList.add("header__main-nav--show");
12    ham.classList.toggle("change")
13  }
14}
15
16var menuLinks = document.querySelectorAll(".header__main-link")
17
18menuLinks.forEach(
19  function (menuLink) {
20    menuLink.addEventListener("click", toggleMenu)
21  }
22)
similar questions
queries leading to this page
js change hamburger 26 show menu