I try to loop some div's, and I have that code:
var first = ".first";
for (i = 0; i < 9999; i++) {
setTimeout(function () {
$(first).delay(500).animate({
"opacity": "1"
}, 1500);
$(first).delay(1500).animate({
"opacity": "0"
}, 1500);
$(".1").delay(4500).animate({
"opacity": "1"
}, 1500);
$(".1").delay(1500).animate({
"opacity": "0"
}, 1500);
$(".2").delay(4800).animate({
"opacity": "1"
}, 1500);
$(".2").delay(1500).animate({
"opacity": "0"
}, 1500);
$(".3").delay(5300).animate({
"opacity": "1"
}, 1500);
$(".3").delay(1500).animate({
"opacity": "0"
}, 1500);
$(".4").delay(5600).animate({
"opacity": "1"
}, 1500);
$(".4").delay(1500).animate({
"opacity": "0"
}, 1500);
$(".5").delay(5900).animate({
"opacity": "1"
}, 1500);
$(".5").delay(1500).animate({
"opacity": "0"
}, 1500);
}, 6000);
}
I tried without setTimeout and effect was the same - divs was appeared and disappeared only in 1st loop. In each next loop they're appeared in random order. I know, that method is wrong, but I'm green with JavaScript and I have no idea how to do it correct. Someone can help me?