Hello stackoverflow community,
my goal is to create changing text with different duration, meaning that there are certain "markers" or sentences which stay longer then the 2 seconds I have now as of now. Also, I would like the animation to stop after all the list entries have been displayed.
Here is the code I have for now:
Javacript:
var terms = $("ul li");
function rotateTerm() {
var ct = $("#rotate").data("term") || 0;
console.log(terms.eq([ct]).text());
$("#rotate").data("term",
ct == terms.length -1 ? 0 : ct + 1).text(terms.eq([ct]).text())
.fadeIn().delay(2000).fadeOut(200, rotateTerm);
}
$(rotateTerm);
HTML
<p><span id="rotate">default</span></p>
<ul style="display:none">
<li>This is sentence number one.</li>
<li>That is sentence number two.</li>
<li>This is another sentence.</li>
<li>Another sentence.</li>
</ul>
Thank you!