How To Make This Slider Auto Play?
I am trying to get this slider to auto play in Javascript (jquery) but I can't seem to get it to work, Does anyone know how I can achieve this? Every time I tried something it seem
Solution 1:
Neil's answer is correct, but if you want it to automatically play when the page loads, you can add this to your variable declarations:
var auto = setInterval(moveRight, 1000); // 1000 ms = 1 sec
like so:
var slideCount = $('#slider ul li').length;
var slideWidth = $('#slider ul li').width();
var slideHeight = $('#slider ul li').height();
var sliderUlWidth = slideCount * slideWidth;
var auto = setInterval(moveRight, 1000); // 1000 ms = 1 sec
Solution 2:
just add the following code -
var auto = setInterval(moveRight, 1000); // 1000 ms = 1 sec
after :
$('a.control_next').click(function () {
moveRight();
});
//any where after the declaration of moveRight function.
whats happening is that, the moveRight function is being called after every 1000 ms. JS FIDDLE of the edited code
Post a Comment for "How To Make This Slider Auto Play?"