jquery animate scrolltop to element code example
Example 1: scroll to element jquery
$('html, body').animate({
scrollTop: $("#grepperRocks").offset().top
});
Example 2: jquery scroll to element
$("#button").click(function() {
$([document.documentElement, document.body]).animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
Example 3: jquery scrolltop animate
var body = $("html, body");
body.stop().animate({scrollTop:0}, 500, 'swing', function() {
alert("Finished animating");
});