JSFiddle - React, Tailwind, and code Playground
HTML
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<a class="scrollup" href="#">Scroll</a>
CSS
.scrollup {
height: 38px;
width: 38px;
opacity: 1.0;
position:fixed;
bottom: 35px;
right: 35px;
background: url(images/top.png) no-repeat;
}
JavaScript
// scroll-to-top button show and hide
jQuery(document).ready(function(){
jQuery(window).scroll(function(){
if (jQuery(this).scrollTop() > 100) {
jQuery('.scrollup').fadeIn();
} else {
jQuery('.scrollup').fadeOut();
}
});
// scroll-to-top animate
jQuery('.scrollup').click(function(){
jQuery("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
});