<script>
/* The purpose of the script is to have the aria-expanded and aria-controls attributes for web accessibility.
You can remove this script and the accordion will still work. */
const btnFaq = document.querySelectorAll('.faq-5__question');
const contentFaq = document.querySelectorAll('.faq-5__answer');
btnFaq.forEach((button) => {
button.addEventListener('click', () => {
// Gets the current state of the button
const isExpanded = button.getAttribute('aria-expanded') === 'true';
// Reset all buttons to "false".
btnFaq.forEach((currentBtn) => {
currentBtn.setAttribute('aria-expanded', 'false');
});
// Changes the status of the current button
button.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
});
});
// Load function after HTML content is loaded
document.addEventListener('DOMContentLoaded', function () {
// Make a tour on each button there is
btnFaq.forEach((button, i) => {
const contentId = contentFaq[i].getAttribute('id');
button.setAttribute('aria-controls', contentId);
});
});
</script>