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

133
Views
my if condition wont hide accordingly my next and previous buttons

I need a if condition which hides the first page=1 previous button, and on page 8 it hides the next button i did use the below code and try but it is not hiding accordingly:

var page = 8;
if(page == 0){
    $("#prev-button").hide();
    $("#next-button").show();
}else if (page == 8) {
    $("#prev-button").show();
    $("#next-button").hide();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="load-more"  id="next-button">
  <a href="${nextUrl}" class="btn-on-white white">Next</a>
</div>  

<div class="previous" id="prev-button">
  <a href="${prevUrl}" class="btn-on-white-test white">Prev</a>
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Maybe this will help you on what you're trying to achieve:

      var page = 0;
      $("#prev-button").hide();
      $("#next-button").show();

      function showBoth() {
        if (page < 8 && page > 0) {
          $("#prev-button").show();
          $("#next-button").show();
        }
      }

      $("#prev-button").on("click", function () {
        page--;
        showBoth();
        if (page == 0) $(this).hide();
      });
      $("#next-button").on("click", function () {
        page++;
        showBoth();
        if (page == 8) $(this).hide();
      });
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!