JSFiddle - React, Tailwind, and code Playground

by End_i

HTML

<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>

CSS

.element {
    margin:5px 0;
    background-color:red;
    border:1px solid #000;
    height:20px;
}

JavaScript

/***
 * Fonction JQuery wait()
 * Ceci permet de mettre un délai à tout appel JQuery
 * Utilisation :   $('.elements').fadeOut().wait(2000).fadeIn();
***/
$(function(){
    jQuery.fn.wait = function(time){
        var $this = $(this);
        $this.queue(function(){
            setTimeout(function(){
                $this.dequeue();
            }, time);
        });
        
        return $this;
    };
});




// Utilisation
$(document).ready(function() {
    $('div.element').fadeOut().wait(2000).fadeIn();
});