File size: 750 Bytes
7a28073
 
305b068
7a28073
 
 
 
 
305b068
 
 
 
 
7a28073
 
305b068
7a28073
 
 
 
 
 
 
 
 
305b068
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
const tabs = document.querySelectorAll('.tabs input[type="radio"]');
const tabContents = document.querySelectorAll('.tab-content');
const tabLabels = document.querySelectorAll('.tabs label'); // Assuming you have labels

function showTab(tabIndex) {
  tabContents.forEach(content => {
    content.classList.remove('active');
  });
  
  tabLabels.forEach(label => {
    label.classList.remove('active'); // Remove 'active' from all labels
  });
  
  tabs[tabIndex].checked = true;
  tabContents[tabIndex].classList.add('active');
  tabLabels[tabIndex].classList.add('active'); // Add 'active' to the clicked label
}

tabs.forEach((tab, index) => {
  tab.addEventListener('click', () => {
    showTab(index);
  });
});

// Show initial tab
showTab(0);