JSFiddle - React, Tailwind, and code Playground

by nicolapeluchetti

HTML

<form>
    <input type="button" value="200 wpm" onclick="rotateTerm()" />
</form>
<p><span id="rotate"></span></p>

JavaScript

var terms = ["term 1", "term 2", "term 3"]; //array of terms to rotate

function rotateTerm() {
    var ct = $("#rotate").data("term") || 0;

    if (ct == 3) {
        $("#rotate").data("term", 0)
        return;
    }
    $("#rotate").data("term", ct == terms.length ? 0 : ct + 1).text(terms[ct]).fadeIn().delay(2000).fadeOut(200, rotateTerm);
}