generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (37 loc) · 1.33 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
const menuBtn = document.querySelector('.ham-burger');
const closeBtn = document.querySelector('.cross');
const content = document.querySelector('.mobile-links');
const link1 = document.querySelector('.mob-link1');
const link2 = document.querySelector('.mob-link2');
const link3 = document.querySelector('.mob-link3');
const link4 = document.querySelector('.mob-link4');
const link5 = document.querySelector('.mob-link5');
const link6 = document.querySelector('.mob-link6');
function showMenu() {
content.style.display = 'flex';
menuBtn.style.display = 'none';
}
function hideMenu() {
content.style.display = 'none';
menuBtn.style.display = 'block';
}
menuBtn.addEventListener('click', showMenu);
closeBtn.addEventListener('click', hideMenu);
link1.addEventListener('click', hideMenu);
link2.addEventListener('click', hideMenu);
link3.addEventListener('click', hideMenu);
link4.addEventListener('click', hideMenu);
link5.addEventListener('click', hideMenu);
link6.addEventListener('click', hideMenu);
function myFunction(desktopView) {
if (desktopView.matches) {
content.style.display = 'none';
menuBtn.style.display = 'none';
} else {
menuBtn.style.display = 'block';
content.style.display = 'none';
}
}
const desktopView = window.matchMedia('(min-width: 768px)');
myFunction(desktopView);
desktopView.addListener(myFunction);