-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (31 loc) · 1.2 KB
/
script.js
File metadata and controls
38 lines (31 loc) · 1.2 KB
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 tabContent = document.querySelectorAll('.info-tabcontent'), //Content
tab = document.querySelectorAll('.info-header-tab'), // Tabs
info = document.querySelector('.info-header'); // Tab parent
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(e){
let target = e.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;
}
}
}
});
});