Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

FAQ-accordion

zaram 20

@blck-zed

Desktop design screenshot for the FAQ accordion coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


please suggest how i the js code i can write so when i click on a detail, the next one closes

Community feedback

@JessyTsiriniaina

Posted

You can do it by masking all the detail the show the one where the onclick event is called

for (let index = 0; index < question.length; index++) {

question[index].addEventListener("click", function () {


    if (reponse[index].style.display == "none") {

        for (let i = 0; i < reponse.length; i++) {

            signe[i].src = "images/icon-plus.svg";
            reponse[i].style.display = "none";

        }
        reponse[index].style.display = "block";
        signe[index].src = "images/icon-minus.svg";
    }

    else {

        signe[index].src = "images/icon-plus.svg";
        reponse[index].style.display = "none";
    }
})

}

Variable: 'reponse' is the answer 'signe' represents the minus and plus sign

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord