-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
33 lines (32 loc) · 1.18 KB
/
scripts.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
window.addEventListener("load", () => {
// Get elements from page
const button = document.getElementById("site_menu_button");
const menu = document.getElementById("dropdown-menu");
const xSign = document.getElementById("xSign");
const plusSign = document.getElementById("plusSign");
// Use plus sign button to toggle menu
button.addEventListener("click", () => {
if (menu.style.display == "none"){
menu.style.display = "inline";
button.style.color = "white";
// Switch button style when menu open
plusSign.style.display = "none";
xSign.style.display = "inline";
}
else{
plusSign.style.display = "inline";
xSign.style.display = "none";
menu.style.display = "none";
}
});
// Close menu when you click on it
menu.addEventListener("click", () => {
menu.style.display = "none";
button.style.display = "inline";
// If x sign is showing, switch back to plus sign
if (xSign.style.display == "inline"){
plusSign.style.display = "inline";
xSign.style.display = "none";
}
});
});