How to add prev/next buttons to a jQuery image gallery? [closed]
I have made a image gallery with jQuery found here:
http://sarfraznawaz2005.kodingen.com/demos/jquery/image_gallery/
I just wanted to know how to I add functionality to prev and next arrow images to show next and previous images with jQuery.
use prev and next to find an element before/after the current one and activate it. You will need to decouple element activation code from the onclick event.
you're using
 $(...).click(function() {
     code
     that 
     activates
     "this"
 });
but now you need to reuse the activation code, so decouple it
 activate = function(elem) {
     code
     that 
     activates
     "elem"
 }
 $(img).click(function() {
     activate(this)
 });
 $(#left).click(function() {
     activate(currentElement.prev())
 });
 $(#right).click(function() {
     activate(currentElement.next())
 });
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论