JSFiddle - React, Tailwind, and code Playground
by videsignz
HTML
<div id="facts">
<span id='remove'>click to cycle</span>
<span>fact 1</span>
<span>fact 2</span>
<span>fact 3</span>
<span>fact 4</span>
</div>
JavaScript
$(document).ready(function() {
var current = 1;
$('#facts span').click(function() {
$('#remove').remove();
// Hide all of them
$('#facts span').hide();
// Unhide the current one:
$('#facts span:eq(' + (current % $('#facts span').length) + ')').show();// Increment the variable
console.log(current % 4);
current++;
});
// Unhide the first one on load
$('#facts span:first-child').show();
});