JSFiddle - React, Tailwind, and code Playground
by Juan Muñoz
HTML
<p><button id="scroll">scrollTop()</button></p>
<div id="test"></div>
CSS
#test {
width: 100px;
height: 100px;
position: relative;
top: 1000px;
background: green;
}
JavaScript
$('#scroll').click(function() {
$('html,body').animate({
scrollTop: $('#test').css('top')
}, 800, function() {
$('html, body').animate({
scrollTop: 0
}, 800);
});
});