Im trying to get an image slider in JQuery to move to the next image after around 2 seconds, ive tried creating a function that should do this on document load but i cant figure it out at all after about 3 hours of exhaustive Googling.
Is there a JQuery class which does this cos i cant find one...
my code for this so far :
$('.slider img:first').addClass('active');
var imagewidth = $('.visible-area').width();
var totalimages = $('.slider img').size();
var sliderwidth = imagewidth * totalimages;
$('.slider').css({'width': sliderwidth});
function autoImage()
{
nextImage();
}
function nextImage()
{
$active = $('.slider img.active').prev();
if ($active.length==0){
$active = $('.slider img:last');
}
$('.slider img').removeClass('active');
$active.addClass('active');
var count = $active.attr('alt') -1;
var sliderposition = count * imagewidth;
$('.slider').hide();
$('.slider').animate({'left': -sliderposition}, 500).fadeIn(1000);
}
thanks