-
Notifications
You must be signed in to change notification settings - Fork 1
/
home.js
43 lines (31 loc) · 1.35 KB
/
home.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
36
37
38
39
40
41
42
let menuOpen = document.getElementById('menuOpen');
let menuClose = document.getElementById('menuClose');
let transparentBackground = document.getElementById('transparentBackground');
menuOpen.addEventListener ('click', function(){
transparentBackground.style.display = "block";
})
menuClose.addEventListener ('click', function (){
transparentBackground.style.display = "none";
})
// FAQ fixed
let questions = document.querySelectorAll('.faq-question');
questions.forEach((question)=>{
question.addEventListener('click', ()=> {
let answer = question.nextElementSibling;
let plusSign = question.querySelector('.plus-sign');
let minusSign = question.querySelector('.minus-sign');
let allAnswers = document.querySelectorAll('.faq-answer');
isExpanded = answer.classList.contains('expanded');
allAnswers.forEach((answer)=> {
answer.classList.remove('expanded');
answer.previousElementSibling.querySelector('.plus-sign').classList.add('show');
answer.previousElementSibling.querySelector('.minus-sign').classList.remove('active');
});
if (!isExpanded) {
answer.classList.add('expanded');
minusSign.classList.add('active');
plusSign.classList.add('none');
plusSign.classList.remove('show');
}
});
});