I’m trying to make 5 divs that loop in and out forever. The divs will have classes “text1” “text2” “text3” etc. Is there anything wrong with this code? It doesn’t seem to work.
$(document).ready(function(){
var num = 1
while(num =< 5) {
$('.text' + num).fadeIn().delay(4000).fadeOut()
var num = num ++i
if(num == 5) {
var num = 1
}
else{
var num = num
}
}
});
Take advantage of a callback function inside the
fadeOutmethod:http://jsfiddle.net/mblase75/NXuVM/2/