JSFiddle - React, Tailwind, and code Playground

HTML

<button class='ip_button'>5</button >

<div class='gallery'></div>

CSS

.gallery {
    background: red;
    height: 100px;
    width: 100px;
    float: left;  
    position: absolute;
}

JavaScript

var gallery_next = function() {    
    $('.gallery').animate({"left" : -300}, 650, function() {
        $('.gallery').css({"left" : 0});
    });
}

$('.ip_button').click(function(){
            var buttonValue, 
                slideTimes;

            buttonValue = $(this).html();
            slideTimes = parseInt(buttonValue);
            for (var i = 0 ; i < 3; i++) { 
                gallery_next();
            }             
        });