Guest User

Untitled

a guest
Jul 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var imgStack = {};
  2. var imgCursor = 0;
  3.  
  4. // bind functionality to clicking next
  5. $("a.next").bind('click', function(event){
  6.    
  7.     // change the image to whats in the stack at the current cursor position
  8.     $(".the-image").attr('src', imgStack[imgCursor]);
  9.  
  10.     // increment the cursor value
  11.     imgCursor = imgCursor + 1;
  12.  
  13.     // get the next image value, so the cursor has something to do if they click next again
  14.     $.get('/location/to/get/next/image/data', function(data){
  15.         imgStack.push(data);
  16.     });
  17. });
  18. // bind functionality to clicking prev
  19. $("a.prev").bind('click', function(event){
  20.    
  21.     // change the image to whats in the stack at the current cursor position
  22.     $(".the-image").attr('src', imgStack[imgCursor]);
  23.  
  24.     // increment the cursor value
  25.     imgCursor = imgCursor - 1;
  26.  
  27.     // get the next image value, so the cursor has something to do if they click next again
  28.     $.get('/location/to/get/prev/image/data', function(data){
  29.         imgStack.push(data);
  30.     });
  31. });
Add Comment
Please, Sign In to add comment