Suppose the array is 1000 in length. I am trying to create a simple way to cross the image paths stored in the array without going beyond. The method below handles the wrapper using the module well when you need to click the "Next" button to increase the index of the array, but not when I have to reduce and subtract one from the index (when the user clicks the previous button).
I am basically trying to do the following:
998 -> click next -> 999 999 -> click next -> 0 0 -> click previous -> 999
My javacript
var index = 0; $('.catalog-img-container').attr("src", javascript_array[index]); $(".next").click(function(){ $('.catalog-img-container').attr("src", javascript_array[++index%arrayLength]); }); $(".previous").click(function(){ $('.catalog-img-container').attr("src", javascript_array[--index]); alert(index);
I appreciate any help with
Thanks a lot in advance.
Anchovylegend
source share