scrollTop() code example
Example 1: scroll to element jquery
$('html, body').animate({
scrollTop: $("#grepperRocks").offset().top
});
Example 2: scrool to top jquerry
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
Example 3: jquery get document scrolltop
var top = ($(window).scrollTop() || $("body").scrollTop());
Example 4: scroll position
$(window).scroll(function() {
var $height = $(window).scrollTop();
if($height > 50) {
} else {
}
});