This little jQuery snippet adds a smooth scroll-to-top effect on a page. Unlike some other methods, this doesn’t need an anchor for the scroll effect to work on a page.
You can change the scroll speed and “scroll up to” position in this script.
$(document).ready(function(){
$(".top").click(function(e){
e.preventDefault();
$("body,html").animate({
scrollTop: 0 // Top position
},800); // Scroll speed
});
});