JSFiddle - React, Tailwind, and code Playground

by Roberts

HTML

<div id="block">
  <a href="#section2">Click me</a>
</div>
<div id="section2">
</div>

CSS

#block {
  background:black;
  width:100%;
  height:2000px;
}
#section2 {
  background:purple;
  width:100%;
  height:2000px;
}

JavaScript

$('a[href*="#section2"]').on('click', function (e) {
	e.preventDefault();

	$('html, body').animate({
		scrollTop: $($(this).attr('href')).offset().top
	}, 500, 'linear');
});