Next/prev Buttons Onclick Scroll To Next And Previous 's
I'm still learning JavaScript and need some help. I am making next and previous buttons that cause a scroll to the next or previous 's on the page. I'm trying to implemen
Solution 1:
Try:
scrollLeft: $("td").next().offset().left
Solution 2:
The following keeps track of your current item to view. You'll need a similar thig to decrement the index in your 'prev' routine.
You may also need to add a delay or an event cut-off so that multiple clicks during animation don't take the value of currentIdx above or below the range of items you have to show.
var currentIdx = 0;
jQuery.easing.def = "easeInOutQuad";
$("#next").click(function (){
//$(this).animate(function(){
$('html, body').animate({
scrollLeft: $("td").eq(currentIdx).offset().left
}, 600);
currentIdx++;
//});
});
Post a Comment for "Next/prev Buttons Onclick Scroll To Next And Previous 's"