-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
43 lines (38 loc) · 1.16 KB
/
js.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
const tabItems = document.querySelectorAll('.tab-item');
const tabContentItems = document.querySelectorAll('.tab-content-item');
// Select tab content item
function selectItem(e) {
// Remove all border classes and add hidden classes
removeBorder();
addHidden();
removeWhite();
// Add border to current tab item и класс white-active в выбранную кнопку
this.classList.add('tab-border');
this.classList.add('white-active');
// Grab content item from DOM
const tabContentItem = document.querySelector(`#${this.id}-content`);
// Remove hidden class
tabContentItem.classList.remove('hidden');
}
// Remove bottom borders from all tab items
function removeBorder() {
tabItems.forEach(item => {
item.classList.remove('tab-border');
});
}
// Удаление подсветки клавиш выбора
function removeWhite() {
tabItems.forEach(item => {
item.classList.remove('white-active');
} );
}
// Add hidden class from all content items
function addHidden() {
tabContentItems.forEach(item => {
item.classList.add('hidden');
});
}
// Listen for tab item click
tabItems.forEach(item => {
item.addEventListener('click', selectItem);
});