Submitted
Faq-accordion
- HTML
- CSS
- JS
What are you most proud of, and what would you do differently next time?
I wrote the code with little or no assistance from outside. I used my initiative and problem-solving skills to put the solution together.
What challenges did you encounter, and how did you overcome them?
During the challenge I had a hard time trying to add an event listener to the tiles such that when clicked on, it would reveal its content. So I wound up giving all the tiles the same class name and then accessing them from JavaScript via className. This returned a collection which I changed into an array using the spread [...arr]
operator. Using the forEach()
method, I added an event listener to each tile such that when any tile is clicked, it closes all other tiles and reveal only its content.
What specific areas of your project would you like help with?
My biggest challenge was making the tiles in the accordion close when clicked on a second time. So I used a loop to add a hide
class to all the tiles and then toggle the current tile that is clicked on open to reveal its content and change the icon from a plus sign +
to a minus sign -
. However, I wanted the tile to close, if open, upon a second click, but to no avail. I would appreciate it if you could share with me how I can go about closing a tile that is been open already when it is being clicked on a second time.