Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript problem in Jquery horizontal slider Re: problem in Jquery horizontal slider

#102005
Mottie
Member

Try this (demo):

$(function() {
var $current = $("#container li"),
len = $current.length-1,
current = 0;

$("#next, #prev").click( function(){
current += (this.id === 'next') ? 1 : -1;
if (current < 0) {
current = 0;
return;
}
if (current > len) {
current = len;
return;
}
$current.animate({
left: -790*current,
top: 0
});
});
});‚Äč