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

117
Visualizações
Show Each Section Per button Click

everyone.

I would like to ask if it is possible to show each section per button click in JQuery or JS?

<section style="display: none;">section1<section> 
<section style="display: none;">section2<section> 
<section style="display: none;">section3<section> 
<section style="display: none;">section4<section> 
<section style="display: none;">section5<section> 
<section style="display: none;">section6<section> 

<button>Show each per click</button>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You'll need to use index() function .. See the next example

$("button").on("click" , () => {
  let index = !$("section.show").length ||  $("section.show").index() == $("section").length ? 0 : $("section.show").index();
  $("section")                         // all sections
    .removeClass("show")               // remove show class to hide all sections
    .filter("section:eq("+index+")")   // desired section by index
    .addClass("show");                 // show the section
});

// to show spacific section
// index starts from 0 so 0 mean the first section change 0 to 1 or 2 ... and try it
$("section").eq(0).addClass("show");
section{
  display : none;
}
section.show{
  display : block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>section1</section> 
<section>section2</section> 
<section>section3</section> 
<section>section4</section> 
<section>section5</section> 
<section>section6</section> 

<button>Show each per click</button>

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