Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var imgStack = {};
- var imgCursor = 0;
- // bind functionality to clicking next
- $("a.next").bind('click', function(event){
- // change the image to whats in the stack at the current cursor position
- $(".the-image").attr('src', imgStack[imgCursor]);
- // increment the cursor value
- imgCursor = imgCursor + 1;
- // get the next image value, so the cursor has something to do if they click next again
- $.get('/location/to/get/next/image/data', function(data){
- imgStack.push(data);
- });
- });
- // bind functionality to clicking prev
- $("a.prev").bind('click', function(event){
- // change the image to whats in the stack at the current cursor position
- $(".the-image").attr('src', imgStack[imgCursor]);
- // increment the cursor value
- imgCursor = imgCursor - 1;
- // get the next image value, so the cursor has something to do if they click next again
- $.get('/location/to/get/prev/image/data', function(data){
- imgStack.push(data);
- });
- });
Add Comment
Please, Sign In to add comment