JSFiddle - React, Tailwind, and code Playground

by Alagar Kamuthurai

HTML

<div class="first"><button type="button">Click Me!</button></div>
<div class="second">Hi
<button type="button" class="button1">Click Me!</button></div>

CSS

.first {
    width: 100%;
    height: 1000px;
    background: #ccc;
}

.second {
    width: 100%;
    height: 1000px;
    background: #999;
}

JavaScript

$("button").click(function() {
    $('html,body').animate({
        scrollTop: $(".second").offset().top},
        'slow');
});

$(".button1").click(function() {
    $('html,body').animate({
        scrollTop: $(".first").offset().top},
        'slow');
});