-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (27 loc) · 1.11 KB
/
script.js
File metadata and controls
28 lines (27 loc) · 1.11 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
document.querySelectorAll('.tab').forEach(tab => {
tab.addEventListener('click', function() {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
this.classList.add('active');
const tabName = this.getAttribute('data-tab');
fetch('tabs/' +tabName + '.html')
.then(response => response.text())
.then(html => {
document.querySelectorAll('.tab-content').forEach(tc => tc.style.display = 'none');
let container = document.getElementById(tabName);
if (!container) {
container = document.createElement('div');
container.className = 'tab-content';
container.id = tabName;
document.querySelector('nav').after(container);
}
container.innerHTML = html;
container.style.display = '';
});
});
});
document.addEventListener("DOMContentLoaded", function() {
var activeTab = document.querySelector('.tab.active');
if (activeTab) {
activeTab.click();
}
});