JSFiddle - React, Tailwind, and code Playground

by tblanco

HTML

<div id="quoteDisplay"></div>
<button id="c">change</button>

JavaScript

var fragments = shuffle(["quote1", "quote2", "quote3", "etc", "ctr", "lalla"])
$('#c').click(function() {
  change(500);
});

function change(time) {
  $('#quoteDisplay').animate({
    opacity: 0
  }, time, function() {
    $('#quoteDisplay').html(fragments.pop()).animate({
      opacity: 1
    }, time)
  });
}

function shuffle(o) { //v1.0
  for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
  return o;
};
change(0);