JSFiddle - React, Tailwind, and code Playground

by Compay

HTML

<a href="#" class="scrollup">Scroll</a>


<div class="scroller"></div>

CSS

.scrollup{
    width:40px;
    height:40px;
    opacity:0.3;
    position:fixed;
    bottom:50px;
    right:100px;
    display:none;
    text-indent:-9999px;
    /*background: url('icon_top.png') no-repeat;*/
}

.scroller {
    height: 1800px;
}
}

JavaScript

//$(document).ready(function(){ 
    $(window).scroll(function(){
        if ($(".scroller").scrollTop() > 10) {
            $('.scrollup').fadeIn();
        } else {
            $('.scrollup').fadeOut();
        }
    }); 
 
    $('.scrollup').click(function(){
        $("html, body").animate({ scrollTop: 0 }, 600);
        return false;
    });
//});