I'm having a nightmare trying to get some quotes to loop with a delay. I have created the following code:
function loopquotes(){
var items = $('.comment').size();
var randomNum = Math.floor(Math.random()*items+1);
$(".comment:nth-child("+randomNum+")").fadeIn('slow').delay(5000);
$(".comment:nth-child("+randomNum+")").fadeOut('medium');
}
This fades in and out nicely with the delay. However, the loop keeps looping without using the delay and I end up with loads of quotes on the page. Can anybody help me loop this properly so that a new quote is only loaded after the old one has faded out.
Many thanks
David