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

116
Views
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 answers
Answer question

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 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!