Spaces:
Running
Running
Create scripts.js
Browse files- scripts.js +19 -0
scripts.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const tabs = document.querySelectorAll('.tabs input[type="radio"]');
|
2 |
+
const tabContents = document.querySelectorAll('.tab-content');
|
3 |
+
|
4 |
+
function showTab(tabIndex) {
|
5 |
+
tabContents.forEach(content => {
|
6 |
+
content.classList.remove('active');
|
7 |
+
});
|
8 |
+
tabs[tabIndex].checked = true;
|
9 |
+
tabContents[tabIndex].classList.add('active');
|
10 |
+
}
|
11 |
+
|
12 |
+
tabs.forEach((tab, index) => {
|
13 |
+
tab.addEventListener('click', () => {
|
14 |
+
showTab(index);
|
15 |
+
});
|
16 |
+
});
|
17 |
+
|
18 |
+
// Show initial tab
|
19 |
+
showTab(0);
|