Using jQuery to change text after set time, and repeat infinitely
<p>I found this answer:</p>

<p><a href="http://stackoverflow.com/questions/8630722/how-can-i-change-text-after-time-using-jquery">How can I change text after time using jQuery?</a></p>

<p>Which basically does what I need. But instead of having it redirect to another page at the end, I want it to just keep cycling through the text messages infinitely. Obviously, I remove the IF section to stop the redirecting, but how do I make it repeatedly cycle through the text messages?</p>

<pre><code>&gt;   function nextMsg() {
&gt;     if (messages.length == 0) {
&gt;         // once there is no more message, do whatever you want
&gt;         alert("redirecting");
&gt;     } else {
&gt;         // change content of message, fade in, wait, fade out and continue with next message
&gt;         $('#message').html(messages.pop()).fadeIn(500).delay(1000).fadeOut(500,
&gt; nextMsg);
&gt;     } }; // list of messages to display var messages = [
&gt;     "Hello!",
&gt;     "This is a website!",
&gt;     "You are now going to be redirected.",
&gt;     "Are you ready?",
&gt;     "You're now being redirected..." ].reverse();
&gt; 
&gt; // initially hide the message $('#message').hide();
&gt; 
&gt; // start animation nextMsg();
</code></pre>
