JSFiddle - React, Tailwind, and code Playground

by Juan Muñoz

HTML

<p><button id="scroll">scrollLeft()</button></p>

<div id="test"></div>

CSS

#test {
    width: 100px;
    height: 100px;
    background: green;
    position: relative;
    left: 1000px;
}

JavaScript

$('#scroll').click(function() {
    $('html,body').animate({
        scrollLeft: $('#test').css('left')
    }, 800, function() {

        $('html, body').animate({
            scrollLeft: 0
        }, 800);

    });
});