Question

I have a slider which uses the following buttons for navigation. How would I add an autoplay feature to this - SetTimeout function?

Thanks

// Next Clicked jQuery('.ajax-next').click(function(){

        if ( jQuery(".ajax-portfolio-window").is(':animated') || jQuery(".ajax-portfolio-image-wrap").is(':animated') ) return;

        var total = jQuery('.portfolio-ajax').length;
        var index = jQuery('.ajax-gallery-navigation').attr("id");

        currindex=parseInt(index);
        nextIndex=currindex+1;
        if (nextIndex!=total) {
            jQuery('.portfolio-ajax').eq(nextIndex).trigger('click');
        }

        return false;


    });



    // Clicked Prev 

    jQuery('.ajax-prev').click(function(){

        if ( jQuery(".ajax-portfolio-window").is(':animated') || jQuery(".ajax-portfolio-image-wrap").is(':animated') ) return;

        var index = jQuery('.ajax-gallery-navigation').attr("id");
        if (index=='-1') { index='0'; }
        currindex=parseInt(index);
        prevIndex=currindex-1;
        if (prevIndex!=-1) {
            jQuery('.portfolio-ajax').eq(prevIndex).trigger('click');
        }

        return false;
    }); 
}
Était-ce utile?

La solution

Here is the code to do this...

setInterval(function()
{
    // do you stuff here. for example
    jQuery('.ajax-next').click();
}, 10000); // 10 sec interval
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top