-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
45 lines (37 loc) · 1.24 KB
/
main.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
43
44
45
// For navbar
window.addEventListener("scroll", () =>{
// When we will scroll 0 px then the window-scroll class wil be toggled
document.querySelector('nav').classList.toggle('window-scroll', window.scrollY > 0);
})
// For faqs
const faqs = document.querySelectorAll('.faq');
faqs.forEach(faq =>{
faq.addEventListener('click', ()=>{
faq.classList.toggle('open');
// Changing the icon
const icon = faq.querySelector('.faq__icon i');
if(icon.className === 'uil uil-plus')
{
icon.className = 'uil uil-minus';
}
else
{
icon.className = 'uil uil-plus';
}
})
})
// -------------------Navbar------------------------------
const menu = document.querySelector('.nav__menue');
const menuBtn = document.querySelector('#open-menue-button');
const closeBtn = document.querySelector('#close-menue-button');
menuBtn.addEventListener('click', () =>{
menu.style.display = "block";
closeBtn.style.display = 'inline-block';
menuBtn.style.display = 'none';
});
const closeNavbar = () =>{
menu.style.display = "none";
closeBtn.style.display = 'none';
menuBtn.style.display = 'inline-block';
}
closeBtn.addEventListener('click', closeNavbar);