Hi. I am trying to get my own image slider to auto play with an interval of 4000 milliseconds. I've tried using setTimeOut but I cannot seem to get it to work. I would appreciate it if someone could help me out. Here is example of the slider:
http://www.matthewruddy.com/slider-intervalissue/
Any ideas how I can get it to auto play?
Here is the jQuery code: // Javascript Document
$(document).ready(function(){
var images = $('.slider li');
var slides = images.length;
var sliderwidth = 500;
var currentimage = 0;
var containerwidth = sliderwidth*slides;
var autoplay = 4000;
$('.slider').css('width', containerwidth);
$('#next').bind('click',nextimage);
function nextimage(){
if(currentimage<slides-1){
currentimage++;
$('.slider').animate({left:-sliderwidth*(currentimage)},{duration:800,easing:'easeInOutCubic'});
}
else{
currentimage = 0;
$('.slider').animate({left:0},{duration:800,easing:'easeInOutCubic'})
}
};
});
Thanks, Matthew