I'm working on creating a unique accordion-style widget similar to the design shown in this image:
https://i.sstatic.net/EBymf.png
My plan is to utilize an ordered list where each <li>
element will include a question, answer, and an expand/collapse button.
<li>
<span class="question">Example question</span>
<span class="answer">Example answer</span>
<a class="expand-collapse-button" href="#"></a>
</li>
One challenge I am facing is how to display the index of each list item within its child element without relying on Javascript. In other words, I want the <span class="question">
element to show the respective parent's index like so: 1. Example question
.