window.addEventListener('load', function () { const accordions = Array.from(document.querySelectorAll('.acf-accordion')) .filter(acc => acc.offsetParent !== null); // only visible ones if (!accordions.length) return; // Open first visible const first = accordions[0].querySelector('details'); if (first) first.open = true; // Make them behave like one accordion accordions.forEach(acc => { const item = acc.querySelector('details'); if (!item) return; item.addEventListener('toggle', function () { if (item.open) { accordions.forEach(otherAcc => { if (otherAcc !== acc) { const otherItem = otherAcc.querySelector('details'); if (otherItem) otherItem.open = false; } }); } }); }); });
Skip to content