I got the following code:
window.setInterval(function(){
var id = $('.slidermenu.currentone').attr('data-id');
var newid = parseInt(id) + 1;
//alert(newid + ' - ' + id);
$('.slidermenu.currentone').animate({backgroundColor: 'white'}, 'slow');
$('.slidermenu.currentone').removeClass("currentone");
$('slidermenu[date-id='+newid+']').animate({backgroundColor: '#f3f3f3'}, 'slow');
$('slidermenu[date-id='+newid+']').addClass("currentone");
$('#activeimage img.currentone').fadeOut('slow');
$('#activeimage img.currentone').removeClass("currentone");
$('#activeimage img[data-id='+newid+']').fadeIn('slow');
$('#activeimage img[data-id='+newid+']').addClass("currentone");
}, 3000);
I'm trying to make a function which runs each 3 second, and then make my slider show the next image. well, it works pretty good first time it runs. But second time, it just doesn't work.
I think the problem might be with making the var newid
have the number of from id
, plus 1
.
Also, I actually need it to do this up to number 5, and then after that goes down to number 1 again.