Gabriel
You do not need to rely on delays.
The “right” way to do sequential animations is to use the promise available in the jQuery standard fx animation queue, letting you run anything you want after the animation finishes - in this case, the fade in the next word.
The code can be written in several ways, here is one:
function f(baseID, n, t) { var jq = $("#" + baseID + n); if(jq.length) { jq.fadeIn(t).promise().done(function() { f(baseID, n+1, t); }); } }; f('word', 1, 1000);
Demo
Written like this, the f() function can be reused. For example, you may have two separate series of attenuation:
f('word', 1, 1000); f('other', 1, 1000);
Demo
source share