JSFiddle - React, Tailwind, and code Playground
HTML
<div id="top">
<button id="clickme">Click Me</button>
</div>
<div id="middle">
</div>
<div id="bottom">
</div>
CSS
#top {
height:500px;
width:200px;
border:2px solid blue;
}
#middle {
height:500px;
width:200px;
border:2px solid red;}
#bottom {
height:500px;
width:200px;
border:2px solid yellow;}
JavaScript
// var pathName = window.location.pathname;
var url = "http://site.com/file.htm#middle";
var hash = url.substring(url.indexOf('#'));
$("#clickme").click(function(){
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 2000);
});