-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
38 lines (31 loc) · 1.08 KB
/
script.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
window.addEventListener('DOMContentLoaded', function() {
'use strict';
let tab = document.querySelectorAll('.info-header-tab'),
info = document.querySelector('.info-header'),
tabContent = document.querySelectorAll('.info-tabcontent');
function hideTabContent(a) {
for (let i = a; i < tabContent.length; i++) {
tabContent[i].classList.remove('show');
tabContent[i].classList.add('hide');
}
}
hideTabContent(1);
function showTabContent(b) {
if (tabContent[b].classList.contains('hide')) {
tabContent[b].classList.remove('hide');
tabContent[b].classList.add('show');
}
}
info.addEventListener('click', function (event) {
let target = event.target;
if (target && target.classList.contains('info-header-tab')) {
for (let i = 0; i < tab.length; i++) {
if (target == tab[i]) {
hideTabContent(0);
showTabContent(i);
break;
}
}
}
});
});