I need to animate a scroll from the current screen position, down a set number of pixels.
$('html,body').animate({
scrollTop: $(window).position().top += 100
});
or?
$('html,body').animate({
scrollTop: '+=100px'
});
Just change:
scrollTop: $('body').position().top += 100
To this:
scrollTop: $(window).scrollTop() + 100
See demo: http://jsfiddle.net/fpxuC/
$('html,body').animate({
scrollTop: $(window).position().top += 100
})
$('html,body').animate({
scrollTop: '+=100px'
})
scrollTop: $('body').position().top += 100
scrollTop: $(window).scrollTop() + 100
Check out the jQuery.ScrollTo plugin. You can do something like: $(...).scrollTo( '+=100px', 800 );
Check out the sample for everything this plugin can do: http://demos.flesler.com/jquery/scrollTo/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With