62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
|
// Find all elements with the class "lcp-accordion"
|
|
var accordions = document.querySelectorAll('.lcp-accordion');
|
|
|
|
accordions.forEach(function (accordion) {
|
|
// Find all tabs within the current accordion
|
|
var tabs = accordion.querySelectorAll('.lcp-accordion-tab');
|
|
|
|
tabs.forEach(function (tab) {
|
|
var header = tab.querySelector('h3');
|
|
var content = tab.querySelector('.lcp-accordion-content');
|
|
|
|
// Add click event to each header to toggle the content
|
|
header.addEventListener('click', function () {
|
|
// Toggle the 'active' class on the tab to show/hide content
|
|
tab.classList.toggle('active');
|
|
|
|
// Optional: Close other open tabs (if only one tab should be open at a time)
|
|
tabs.forEach(function (otherTab) {
|
|
if (otherTab !== tab) {
|
|
otherTab.classList.remove('active');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const tabs = document.querySelectorAll('.tab-link');
|
|
const panes = document.querySelectorAll('.tab-pane');
|
|
|
|
tabs.forEach(tab => {
|
|
tab.addEventListener('click', function (event) {
|
|
event.preventDefault();
|
|
|
|
// Remove active class from all tabs and panes
|
|
tabs.forEach(link => link.classList.remove('active'));
|
|
panes.forEach(pane => pane.classList.remove('active'));
|
|
|
|
// Add active class to the clicked tab
|
|
tab.classList.add('active');
|
|
|
|
// Get the target pane
|
|
const targetPaneId = tab.dataset.tab;
|
|
const targetPane = document.getElementById(targetPaneId);
|
|
|
|
// Check if targetPane exists before trying to manipulate it
|
|
if (targetPane) {
|
|
targetPane.classList.add('active');
|
|
} else {
|
|
console.error(`Tab pane with ID '${targetPaneId}' not found.`);
|
|
}
|
|
});
|
|
});
|
|
});
|