Below code snippet ensures the scrolling top with some actions.
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
}); 'scrollTop' is used to perform scrolling to the top. 'slow' makes theaction slower.