-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (17 loc) · 853 Bytes
/
script.js
File metadata and controls
22 lines (17 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function tabs() {
const tabs = document.querySelectorAll(".tab");
const tabContents = document.querySelectorAll(".tab-content");
const radioButtons = document.querySelectorAll(".radio-button");
tabs.forEach((tab) => {
tab.addEventListener("click", () => {
const tabId = tab.getAttribute("data-tab");
// Hide all tab contents and uncheck all radio buttons
tabContents.forEach((content) => content.classList.remove("active"));
radioButtons.forEach((radio) => (radio.checked = false));
// Show the selected tab content and check the corresponding radio button
document.getElementById(`tab${tabId}-content`).classList.add("active");
document.getElementById(`tab${tabId}`).checked = true;
});
});
}
document.addEventListener("DOMContentLoaded", tabs);