JSFiddle - React, Tailwind, and code Playground

by tmyie

HTML

<div class="container">
    <div class="img">1</div>
    <div class="img">2</div>
    <div class="img">5</div>
    <div class="img">4</div>
    <div class="img">6</div>
</div>

<div class="next">
    Next
</div>

<div class="prev">
    Prev
</div>

CSS

.container {
    height: 100px; width: 100px;
    overflow: hidden;
}

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

.img ~ .img {
    display: none;
}

JavaScript

$('.next').click(function(){
    $('.img:first').fadeOut(function(){
        $(this).next().fadeIn();
    });

});