JSFiddle - React, Tailwind, and code Playground

by Rajesh Dixit

HTML

<span class="text-center"><span class="top-line">A heading here</span>
<br><span class="bottom-line">There once was a...<br>
 <span id="changeTextMobile"></span></span>
</span>

JavaScript

var text = ["carrot", "potato", "tomato", "lettuce", "radish", "cabbage", "melon", "cucumber"];
var counter = 0;

function initInterval(){
    interval = setInterval(function(){
    	counter++;
       	$("#changeTextMobile").text(text[counter%8]); 
    },1200);
}

$(document).ready(function(){
	initInterval();
});