Okay, i've had a quick play and expanded it a little for you..
JS Fiddle: http://jsfiddle.net/4k3zfv5f/
function rotate(sID,aWords, iIndex){
$("#"+sID).html(aWords[iIndex]).fadeIn(1000, function() {
iIndex==(aWords.length-1)? iIndex=0:iIndex++;
$("#"+sID).fadeOut(1000, function() {
rotate(sID,aWords,iIndex);
});
});
}
rotate("test1",["Hello", "World", "Foo"], 0);
rotate("test3",["John", "Bob", "Billy", "Mike", "Larry"], 0);
EDIT - UPDATE
Basically there were a few corrections i had to make, so instead of going over each one.. Will just let you compare the changes.. Part of it is that the fade functions did not wait til they completed, the Delay command only applies to the jquery object and the append i reversed just for my visual sake.
Also the last part as you mentioned in the comments, was to swap appendTo with html.
Just as an extra bonus, a shuffle example:
JS Fiddle Showing With Shuffle Example: http://jsfiddle.net/ye3rjy2v/1/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…