Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

282
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda