I am trying to get a JQuery snippet to loop around and keep displaying the messages in the array. This is what I have so far and it works, it just won't loop round after once even though I have the counter set to 100.
What am I doing wrong? What would be best practice and why?
Thanks in advance
function popMessage() {
$('#message').html(messages.pop()).fadeIn(500).delay(1000).fadeOut(500, popMessage);
};
for (var i = 0; i < 100; i++) {
var messages = [
"Message 1",
"Message 2",
"Message 3",
"Message 4",
].reverse();
$('#message').hide();
popMessage();
}