I want to fadeOut the first div every few seconds, this code works once:
$('.comment:first').delay(4000).fadeOut();
and to try and make it run continually I’ve been trying to do a callback function or loop but finding no joy. I’m not familiar with these types of functions. Here is my attempt so far:
$('.comment:first').delay(4000).fadeOut( function(){
$(this).delay(4000).fadeOut();
});
EDIT:
After div.comment:first is faded out, the second div.comment would now be first in line so I want to then fadeOut that div and continually run that function. I do not want the first div.comment to ever fade back in. Sorry for the confusion.
This will stop on the last element as you need it to
(otherwise remove the
ifand use.eq(++C % N)! 🙂jsBin demo
Loop explained:
EDIT
After the OP leaved me a comment:
jsBin demo