Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda