JSFiddle - React, Tailwind, and code Playground

by oilvier

HTML

<button type="button" id="go">Go!</button>
<section></section>
<section id="toto"></section>

CSS

section {height: 1000px; background:red; margin: 10px;}

JavaScript

var trigger = document.getElementById("go");
var element = document.getElementById("toto");

trigger.addEventListener('click', function(event) {
  element.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
}, false);