-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwide.js
More file actions
25 lines (21 loc) · 731 Bytes
/
wide.js
File metadata and controls
25 lines (21 loc) · 731 Bytes
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
const tabItems = document.querySelectorAll(".tab-item");
const tabContentItems = document.querySelectorAll(".tab-content-item");
// Select tab content
function selectItem(e) {
removeBorder();
removeShow();
// Add border to current tab
this.classList.add("tab-border");
// Grab content item from DOM
const tabContentItem = document.querySelector(`#${this.id}-content`);
// Add show class
tabContentItem.classList.add("show");
}
function removeBorder() {
tabItems.forEach((item) => item.classList.remove("tab-border"));
}
function removeShow() {
tabContentItems.forEach((item) => item.classList.remove("show"));
}
// Listen for tab click
tabItems.forEach((item) => item.addEventListener("click", selectItem));