JSFiddle - React, Tailwind, and code Playground
by Dineshkani
HTML
<div id="firstdiv" class="sample">
Hello Jquery
</div>
<div id="space">Space</div>
<div id="tops">Click to Go Top</div><br/><br/>
<div id="wanimate">Top</div>
CSS
.sample{
font-size: 35px;
color: blue;
}
#space{
visibility: hidden;
height: 800px;
}
#tops,#wanimate{
color: white;
height: 60px;
width: 80px;
background-color: grey;
position: relative;
bottom: 0px;
cursor: pointer;
text-align:center;
}
JavaScript
//In Jquery
$("#tops").on("click",function(){alert("Position of Scrollbar - " + $("html, body").scrollTop());$('html, body').scrollTop("0px")});
$("#wanimate").on("click",function(){$('html, body').animate({"scrollTop" : "0px"})});