JSFiddle - React, Tailwind, and code Playground

by tmyie

HTML

<div class="container">
    <div class="img first">1</div>
    <div class="img">2</div>
    <div class="img">3</div>
    <div class="img">4</div>
    <div class="img">5</div>
</div>
<div class="next">
    Next
</div>
<div class="next">
    Prev
</div>

CSS

.container {
    height: 100px;
    width: 100px;
    border: 1px solid red;
    overflow: hidden;
}

.img {
    width: 100px; height: 100px; background-color: lightgrey;
}

JavaScript

$('.next').click(function(){
    $('.img:first').appendTo('.container');
});

$('.prev').click(function(){
    $('.img:last').prependTo('.container');
});