I'm currently working on implementing an accordion-style FAQ sheet, but I'm facing some issues. Right now, I can only get the first element to display the hidden content. Below is the JavaScript code I am using:
var arrowIcon = document.querySelector('.arrow-icon');
var hidden = document.querySelector('.hidden');
var answer = 'answer';
arrowIcon.addEventListener('click', function() {
if (answer === 'hidden') {
answer = 'answer';
hidden.setAttribute('class', 'answer');
}
else {
answer = 'hidden';
hidden.setAttribute('class', 'hidden');
}
});