JSFiddle - React, Tailwind, and code Playground
HTML
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div id="weblinks">
</div>
<a href="#" id="scrollup">Scroll up</a>
CSS
html {
height: 5000px
}
#weblinks {
background: #4679BD;
}
div {
height: 300px;
width: 100%;
border: 1px solid #ccc;
margin-bottom: 20px;
background: #ddd
}
#scrollup {
width: 100px;
height: 30px;
color: #fff;
background: #ff0000;
position: fixed;
top: 20px;
left: 20px;
display: none;
}
JavaScript
$(document).ready(function () {
var elem = $('#weblinks');
var bottom = $(elem).position().top+$(elem).outerHeight(true)
$(window).scroll(function () {
if ($(this).scrollTop() > bottom) {
$('#scrollup').fadeIn();
} else {
$('#scrollup').fadeOut();
}
});
$('#scrollup').click(function () {
$("html, body").animate({ scrollTop: 0 }, 500);
return false;
});
});