I have an FAQ project in which it has several question that can be answered when the users clicks the arrow button on each questions line. I am using javascript to change the css element but it only works with the firts arrow on not the rest.
I want to be able to click any arrow to show each answer. I was thinking add an differnt ID to each arrow per line but that may not be the best approach.
HTML
<article class="questions">
How many team members can I invite?
<img src="images/icon-arrow-down.svg" alt="arrow" class="arrow" id="down-arrow">
<hr>
<detail id="answer">
You can invite up to 2 additional users on the Free plan. There is no limit on
team members for the Premium plan.
</detail>
</article>
<article class="questions">
What is the maximum file upload size?
<img src="images/icon-arrow-down.svg" alt="arrow" class="arrow" id="down-arrow">
<hr>
<detail id="answer">
No more than 2GB. All files in your account must fit your allotted storage space.
</detail>
</article>
<article class="questions">
How do I reset my password?
<img src="images/icon-arrow-down.svg" alt="arrow" class="arrow" id="down-arrow">
<hr>
<detail id="answer">
Click “Forgot password” from the login page or “Change password” from your profile page.
A reset link will be emailed to you.
</detail>
</article>
<article class="questions">
Can I cancel my subscription?
<img src="images/icon-arrow-down.svg" alt="arrow" class="arrow" id="down-arrow">
<hr>
<detail id="answer">
Yes! Send us a message and we’ll process your request no questions asked.
</detail>
</article>
<article class="questions">
Do you provide additional support?
<img src="images/icon-arrow-down.svg" alt="arrow" class="arrow" id="down-arrow">
<hr>
<detail id="answer">
Chat and email support is available 24/7. Phone lines are open during normal business hours.
</detail>
CSS
#answer{
display: none;
}
Javascript
document.getElementById('down-arrow').addEventListener("click", toggleAnswers);
const arrow = document.getElementById('down-arrow')
const current = document.getElementById("answer");
function toggleAnswers(){
current.style.display = "inline";
arrow.style.transform = "scaleY(-1)";
}

document.getElementById('down-arrow')will no longer work as expected