Skip to content
Caribbean Student Association
document.addEventListener("DOMContentLoaded", function() {
// Get all accordion toggle elements
var accordions = document.querySelectorAll('.accordion-toggle');
// Add click event listeners to each accordion toggle
accordions.forEach(function(accordion) {
accordion.addEventListener('click', function() {
// Get the panel-collapse element directly following this accordion-toggle
var panelCollapse = this.nextElementSibling;
// Check if this panel-collapse is currently open
var isOpen = panelCollapse.classList.contains('open');
// Remove 'open' class from all panel-collapses
accordions.forEach(function(acc) {
var collapse = acc.nextElementSibling;
collapse.classList.remove('open');
});
// Toggle 'open' class only on the clicked panel-collapse
if (!isOpen) {
panelCollapse.classList.add('open');
}
});
});
});