0

I have a thumbnail gallery and I would like it to return to the beginning of the gallery once you have reached the end of the galley but I can't seem to figure out how to achieve this functionality. Here is what I have so far [1]: http://jsfiddle.net/jsavage/vp62g/3/[question]. any help would be greatly appreciated! Thanks!

jsavage980
  • 125
  • 2
  • 4
  • 17

1 Answers1

0

You need some else with your if:

$('div#arrowR').click(function(){
    if(index < endIndex ){
      index++;
      $item.animate({'left':'-=300px'});
    } else {
      index = 0;
      $item.animate({'left':'+='+(300*endIndex)+'px'});  
    }
});

$('div#arrowL').click(function(){
    if(index > 0){
      index--;            
      $item.animate({'left':'+=300px'});
    } else {
      index = endIndex;
      $item.animate({'left':'-='+(300*endIndex)+'px'});
    }
});