Jquery to slide on load
- by Pexsol
I have a simple slider that works on click. How can I automate it so it runs automatically yet keeping the click function as it is?
$(document).ready(function() {
var currentPosition = 0;
var slideHeight = 360;
var slides = $('.main-item');
var numberOfSlides = slides.length;
var tracker = 0;
$('.slider-height').css('height', slideHeight * numberOfSlides);
$('.slide-option li a').click(function() {
tracker = $('.slide-option li a').index($(this));
$('.slide-option li a').removeClass('current-item');
$(this).addClass('current-item');
//alert(tracker);
$('.slider-height').animate({
'top': slideHeight * (-tracker)
});
return false;
//alert(tracker);
});
});