Is it because we want to run this function in loop? or anything else? (This is the code for display of multiple texts with fade in and out effects.)
HTML Code:
<div class="container">
  <h2 class="quotes">first quote</h2>
  <h2 class="quotes">second quote</h2>
  <h2 class="quotes">3rd quote</h2>
  <h2 class="quotes">4th quote</h2>
  <h2 class="quotes">5th quote</h2>
  <h2 class="quotes">6th quote</h2>
</div>
CSS Code:
.quotes {display: none;}
JS Code:
(function() {
  var quotes = $(".quotes");
  var quoteIndex = -1;
  function showNextQuote() {
    ++quoteIndex;
    quotes.eq(quoteIndex % quotes.length)
      .fadeIn(2000)
      .delay(2000)
      .fadeOut(2000, showNextQuote);
  }
  showNextQuote();
})();
 
    