Open One Answer at a Time
Write the code, see it run, pass the checks.
The problem
- medium
- Code
An FAQ has three questions as buttons, "Shipping", "Returns" and "Payment", with the answers "Ships in 2 days.", "Free returns for 30 days." and "We take cards.". All start closed (leave a closed answer out, or keep it with the hidden attribute). Clicking a question opens its answer and closes any other; clicking the open one closes it. Give each button aria-expanded="true" or "false" so screen readers know whether its answer is open.
Your code must pass
- All answers start closed
- Opening one closes the others
- Clicking the open one closes it
- Each button says whether it's expanded