HTML

<div id="top">
    <a href="#top" class="topbutton preventD">TOP</a>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

CSS

#top{width: 100%; height: 2000px;}
#top .topbutton{position: fixed; bottom: 0; right: 0;}

JAVASCRIPT

$(document).ready(function(){
    function preventD(a){
        a.click(function(event){
            event.preventDefault();
        });
    }
    function aniLink(link){
        var target = $(link.attr('href')).offset().top;
        $('html,body').stop().animate({scrollTop:target},800,'swing');
    }

    preventD($('.preventD'));

    $('.topbutton').click(function(event){
        aniLink($(this));
    });
});