Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
How to toggle (On/Off) summery when click on arrow button

I am facing an issue related to the toggle which I want, when I click on any arrow btn, only the clicked btn summary will display. I have tried a lot but am still on the problem side. I have used opacity: 0; instead of display: none; for a paragraph. Sorry! I am in a learning zone and working on some small projects. Thanks for your support.

 <section>
                    <div class="content">
                        <h3>How does it work?</h3>
                        <i id="uparrow" class="fa fa-angle-up"></i>
                    </div>
                    <p id="para">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sequi provident ut sed
                        eaque earum
                        commodi consectetur iandae magnam nostrum gendi veniam voluptate beatae. Non soluta
                        reprehenderit quas dicta?</p>
                </section>
                <section>...</section>
                <section>...</section>
                <section>...</section>


    <script>
     const arrow = document.querySelectorAll('#uparrow');
     const para = document.querySelectorAll('#para');
     const content = document.getElementsByClassName('content');
     for(let i=0; i<arrow.length; i++){
        arrow.addEventListener('click',()=>{
            closeAll();
            openQuest(i);
        })
     }
     function openQuest(i){
        para[i].style.opacity = '1';
        para[i].style.maxHeight = '10rem';
        arrow[i].style.transform = 'rotateX(180deg)';
     }
     function closeAll(){
        for(let i=0; i<content.length; i++){
            arrow[i].style.transform = 'rotateX(0deg)';
            para[i].style.maxHeight = '0rem';
            para[i].style.opacity = '0';
        }
     }
    </script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Why dont you use the <details> tag?

 <section>
                    <div class="content">
                        <h3>How does it work?</h3>
                        <i id="uparrow" class="fa fa-angle-up"></i>
                    </div>
                    <details id="para">
                    <summary>Click me</summary>
                    <p>                    Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sequi provident ut sed
                        eaque earum
                        commodi consectetur iandae magnam nostrum gendi veniam voluptate beatae. Non soluta
                        reprehenderit quas dicta?</p>
                    </details>
                </section>
                <section>...</section>
                <section>...</section>
                <section>...</section>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!