Looping an array with setTimeout

im trying to loop an array with a setTimeout continuously ive tried creating a function with a for loop inside the function then calling the function at the end but have not luck

Id like to ad fadeIn and fadeOut but have had no sucess either.

heres my code

	var anmt1 = "name1";
 	var anmt2 = "name2";
 	var anmtArray = new Array(anmt1,anmt2,anmt3,anmt4);
 	if(!anmtArray.length){
 		$('#ancmtSpan').text("More Announcements coming soor");
 	}
 	else{

 for (var i = 0; i < anmtArray.length; i++) {
     function looping(i, t) {
         setTimeout(function() {
             $('#ancmtSpan').html(anmtArray[i]);
         }, t* i);
     };
     looping(i, 5000);
 }	}

[quote=“adrianmmcg, post:1, topic:287269, full:true”]
im trying to loop an array with a setTimeout continuously ive tried creating a function with a for loop inside the function then calling the function at the end but have not luck[/quote]

Putting your code in JSFiddle it seems to work, looping through each of the announcements.

Is there anything different that it should be doing?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.