prashantcs053
11/7/2017 - 12:02 PM

Fade in & out text loop - jQuery

(function() {

    var quotes = $(".quotes");
    var quoteIndex = -1;
    
    function showNextQuote() {
        ++quoteIndex;
        quotes.eq(quoteIndex % quotes.length)
            .fadeIn(2000)
            .delay(2000)
            .fadeOut(2000, showNextQuote);
    }
    
    showNextQuote();
    
})();
.quotes {display: none;}
<h2 class="quotes">first quote</h2>
<h2 class="quotes">second quote</h2>