add next and previous button in jquery slider

Posted by jignesh kheni on Stack Overflow See other posts from Stack Overflow or by jignesh kheni
Published on 2013-06-27T04:07:31Z Indexed on 2013/06/27 4:21 UTC
Read the original article Hit count: 192

Filed under:

I Made some below script to make simple fadeInOut slideshow. Now I want to add Next/Prv buttton. How can i do it?

'$(document).ready(function(e) {
    var slider ={
        init: function() {   
            var initialFadeIn = 1000;
            var itemInterval = 5000;
            var fadeOut = 2500;
            var numberOfItems = $('.slider-img').length;
            var currentItem = 0;            
            //show first item
            $('.slider-img').eq(currentItem).fadeIn(initialFadeIn);
            //loop through the items
            var infiniteLoop = setInterval(function(){
                $('.slider-img').eq(currentItem).fadeOut(fadeOut);          
                if(currentItem == numberOfItems -1){currentItem = 0;}
                else{currentItem++;}
                $('.slider-img').eq(currentItem).fadeIn(fadeOut);
            }, itemInterval);
        }
    };
    slider.init();  
});'

© Stack Overflow or respective owner

Related posts about jQuery