<div id="top"></div>
<a href="#top">на верх</a>/#top
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = $(this.hash);
$('html, body').stop().animate({
'scrollTop': target.offset().top
}, 500);
});