-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
52 lines (44 loc) · 1.25 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
// For Switching tabs for Feature section
const tabs = document.querySelectorAll(".tab");
const features = document.querySelectorAll(".features-content");
// To add and remove Border
const switchTabs = (e) => {
e.preventDefault();
clearBorder();
clearContent();
e.target.classList.add("show-tab");
switchTabContent();
};
// To switch contents of tab
const switchTabContent = () => {
tabs.forEach((tab, index) => {
tab.classList.contains("show-tab")
? features[index].classList.add("show-content")
: null;
});
};
// For clear content
const clearContent = () => {
features.forEach((feature) => {
feature.classList.contains("show-content")
? feature.classList.remove("show-content")
: null;
});
};
// For removing border
const clearBorder = () => {
tabs.forEach((tab) => {
tab.classList.contains("show-tab")
? tab.classList.remove("show-tab")
: null;
});
};
// Looping through tabs
tabs.forEach((tab) => {
tab.addEventListener("click", switchTabs);
});
// For Mobile Hamburger Toggle
document.querySelector(".menu-btn").addEventListener("click", () => {
const selectUl = document.querySelector(".nav-links");
selectUl.classList.toggle("show");
});