-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (37 loc) · 1.12 KB
/
script.js
File metadata and controls
44 lines (37 loc) · 1.12 KB
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
36
37
38
39
40
41
42
/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = `0`;
} else {
document.getElementById("navbar").style.top = `-85.6px`;
}
prevScrollpos = currentScrollPos;
}
const menu = document.getElementById("menu")
const list = document.getElementById("list")
menu.onclick = function() {
list.classList.toggle("show")
if(menu.classList.contains("fa-bars")){
menu.classList.remove("fa-bars")
menu.classList.add("fa-xmark")
}
else{
menu.classList.remove("fa-xmark")
menu.classList.add("fa-bars")
}
}
const faqs = document.querySelectorAll('#expand');
const info = document.querySelectorAll('.info')
for (let i = 0; i < faqs.length; i++) {
faqs[i].addEventListener("click", function() {
for (let j = 0; j < info.length; j++) {
if (j === i) {
info[j].classList.toggle("in");
} else {
info[j].classList.remove("in");
}
}
});
}