How can I prevent my slideshow buttons from continuing past the last page?

I’m making a complicated show room in WordPress. I am using the posts to do this. It’s actually going very well but I only have one problem: I have a next and prev button that slide the posts from left to right, but when they get to the last post the buttons still work so you get a white space.

This is my code.

Read More
<script>
$("#button-Next").click(function(){
  $("#inside").animate({"left": "-=800px"}, "slow");
  $("#button-Prev").animate({height:32}, "slow");
});

$("#button-Prev").click(function(){
  $("#inside").animate({"left": "+=800px"}, "slow");
});


$(function() {

    var longjohn = getElementById("#inside");

      if (longjohn.left = -1600px) {
          $("#button-Next").animate({height:0}, "slow");
      }

      if (longjohn.left = 0) {
          $("#button-Prev").animate({height:0}, "slow");
      }
      else {
            $("#button-Prev").animate({height:32}, "slow");
            $("#button-Next").animate({height:32}, "slow");
      }

    });

I cant find anything about setting the minimum length or something.

Related posts

Leave a Reply

1 comment

  1. Use a Div to inclose the slide show in, set a class on the div e.g. <div class="myslider"><!-- Your slide show code here --></div> and from there use CSS to restrict the display of the div by setting the CSS properties to .myslider{ display: block; width: 800px; height:300px; margin: 0 auto; change the CSS properties to select what fits your necessary dimensions.

    Alternatively you can set the position of each button using CSS absolute positioning.