-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (31 loc) · 1.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const hamburgerButton = document.querySelector("#hamburger-button");
const hamburgerUl = document.querySelector(".hamburger-ul");
const hamburgerLi = document.querySelectorAll(".hamburger-li");
const navImage = document.querySelector(".nav-image");
let hamburger = true;
const hamburgerTrue = () =>{
hamburgerButton.classList.remove("fa-bars");
hamburgerButton.classList.add("fa-times");
hamburgerUl.style.visibility = "visible";
hamburgerUl.style.opacity = "1";
hamburger = false;
};
const hamburgerFalse = () =>{
hamburgerButton.classList.add("fa-bars");
hamburgerButton.classList.remove("fa-times");
hamburgerUl.style.visibility = "hidden"
hamburgerUl.style.opacity = "0";
hamburger = true;
};
hamburgerButton.addEventListener("click", () =>{
if(hamburger === true) hamburgerTrue();
else hamburgerFalse();
});
hamburgerLi[0].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[1].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[2].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[3].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[4].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[5].addEventListener("click", () =>{ hamburgerFalse(); });
hamburgerLi[6].addEventListener("click", () =>{ hamburgerFalse(); });
navImage.addEventListener("click", () =>{ hamburgerFalse(); });