-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (24 loc) · 959 Bytes
/
script.js
File metadata and controls
32 lines (24 loc) · 959 Bytes
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
// Navigation Menu
let menu = document.querySelector('.navbar__mobile');
let overlay = document.querySelector('.overlay');
menu.addEventListener('click', function() {
this.classList.toggle('active');
this.parentElement.children[2].classList.toggle('active');
overlay.classList.toggle('active');
this.classList.contains('active') ? document.body.style.overflow = 'hidden' : document.body.style.overflow = 'visible';
})
// FAQ Accordion
let items = document.querySelectorAll('.accordion__item');
items.forEach(item => {
item.addEventListener('click', function() {
let answer = this.children[1];
let currentArrow = this.children[0].children[1];
currentArrow.classList.toggle('active');
answer.classList.toggle('active');
if(answer.style.maxHeight) {
answer.style.maxHeight = null;
} else {
answer.style.maxHeight = this.scrollHeight + 'px';
}
});
});