Jquery to slide on load
Posted
by
Pexsol
on Stack Overflow
See other posts from Stack Overflow
or by Pexsol
Published on 2012-10-12T14:08:25Z
Indexed on
2012/10/12
15:37 UTC
Read the original article
Hit count: 162
jquery-ui
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);
});
});?
© Stack Overflow or respective owner