FAQ-accordion

Frontend Mentor - FAQ accordion solution

This is a solution to the FAQ accordion challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

Screenshot

![]url(alt text)

![]url(alt text)

My process

Built with

What I learned

i have leaned to add buttons

<div class="accordion-header" onclick="toggleAccordion(this)">
  <span>Can I use Frontend Mentor projects in my portfolio?</span>
  <div class="accordion-icon plus"></div>

i have learned some Javascript

<script>
  function toggleAccordion(element) {
      // Get the content and icon elements
        const content = element.nextElementSibling;
        const icon = element.querySelector('.accordion-icon');
            
       // Toggle active class on content
        content.classList.toggle('active');
            
      // Toggle between plus and minus icons
      if (content.classList.contains('active')) {
          icon.classList.remove('plus');
          icon.classList.add('minus');
      } else {
          icon.classList.remove('minus');
          icon.classList.add('plus');
      }
    }
  </script>

Author