Jay Wit Jay Wit - 7 months ago 19
Javascript Question

Smooth JavaScript/jQuery scroll to element

I'm trying to make a horizontal scroll website, but I don't know how to smoothly scroll from one element to the other.
I tried the following code:

$("a[href='#top']").click(function() {
$("body").animate({ scrollTop: 0 }, "slow");
return false;
});


But it only scrolls to the top, I also tried the jQuery-plugin ScrollTo, but I just can't get it to work, I also tried the jQuery plugin:

$('.click').click(function(){
$.scrollTo( '.last', 800, {easing:'elasout'});
});


But also without succes.

Does anyone know a good, easy to understand, sample I can use? Thanks in advance!

Answer

untested

   $('.click').click(function(){
        $.scrollTo( $('.last'), 800);
    });
Comments