-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
76 lines (71 loc) · 2.84 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Toggle Links for mobile screen */
const toggleLink = document.querySelector('.toggle-link');
const crossLink = document.querySelector('.cross-link');
const navLinks = document.querySelectorAll('.nav-link');
const toggleMenu = () => {
toggleLink.style.display = 'none';
crossLink.classList.add('show-link');
navLinks.forEach(function (link) {
link.classList.add('show-link');
});
};
const crossMenu = () => {
toggleLink.style.display = 'initial';
crossLink.classList.remove('show-link');
navLinks.forEach(function (link) {
link.classList.remove('show-link');
});
}
toggleLink.addEventListener('click', toggleMenu);
crossLink.addEventListener('click', crossMenu);
/* */
/* create constants of main navigation links */
const productLink = document.getElementById('product-link');
const testimonialLink = document.getElementById('testimonial-link');
const photoBoothLink = document.getElementById('photo-booth-link');
const aboutLink = document.getElementById('about-link');
/** create constants for the page sections */
const productSection = document.getElementById('product-section');
const testimonialSection = document.getElementById('testimonial-section');
const photoBoothSection = document.getElementById('photo-booth-section');
const aboutSection = document.getElementById('about-section');
testimonialSection.style.display = 'none';
photoBoothSection.style.display = 'none';
aboutSection.style.display = 'none';
/** add event listeners to the links to display particular section and hide others */
productLink.addEventListener('click', function (event) {
// navLinks.forEach(function (link) {
// link.classList.remove('show-link');
// })
productSection.style.display = 'block';
testimonialSection.style.display = 'none';
photoBoothSection.style.display = 'none';
aboutSection.style.display = 'none';
})
testimonialLink.addEventListener('click', function (event) {
// navLinks.forEach(function (link) {
// link.classList.remove('show-link');
// })
productSection.style.display = 'none';
testimonialSection.style.display = 'block';
photoBoothSection.style.display = 'none';
aboutSection.style.display = 'none';
})
photoBoothLink.addEventListener('click', function (event) {
// navLinks.forEach(function (link) {
// link.classList.remove('show-link');
// })
productSection.style.display = 'none';
testimonialSection.style.display = 'none';
photoBoothSection.style.display = 'block';
aboutSection.style.display = 'none';
})
aboutLink.addEventListener('click', function (event) {
// navLinks.forEach(function (link) {
// link.classList.remove('show-link');
// })
productSection.style.display = 'none';
testimonialSection.style.display = 'none';
photoBoothSection.style.display = 'none';
aboutSection.style.display = 'block';
})