-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
30 lines (24 loc) · 929 Bytes
/
script.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
const container = document.querySelector(".container");
const navLinks = document.querySelectorAll(".nav-link");
const navOpenIcon = document.querySelector(".open-navbar-icon");
const navCloseIcon = document.querySelector(".close-navbar-icon");
const navBtns = document.querySelectorAll(".navigation-button");
//Click event for button that opens nav
navOpenIcon.addEventListener("click", () => {
container.classList.add("change");
});
//Click event for button that closes nav
navCloseIcon.addEventListener("click", () => {
container.classList.remove("change");
});
//color varieties for nav links
const colors = ["#6495ed", "#7fffd4", "#ffa07a", "#f08080", "#afeeee"];
let i = 0;
Array.from(navLinks).forEach(item => {
item.style.cssText = `background-color: ${colors[i++]}`;
});
Array.from(navBtns).forEach(item => {
item.onclick = () => {
item.parentElement.parentElement.classList.toggle("change");
};
});