I'm working on a website with jQuery 1.4. I cannot update it (which sucks, really).
I have followed @benekastah answer from this question to make a text appear word-by-word. It uses a promise()
method at the end which I can't use, because promise()
is since v. 1.6.
Here's the complete code
var $el = $(".example:first"), text = $.trim($el.text()),
words = text.split(" "), html = "";
for (var i = 0; i < words.length; i++) {
html += "<span>" + words[i] + ((i+1) === words.length ? "" : " ") + "</span>";
};
$el.html(html).children().hide().each(function(i){
$(this).delay(i*200).fadeIn(700);
});
$el.find("span").promise().done(function(){
$el.text(function(i, text){
return $.trim(text);
});
});
The rest of the code is working fine.
My question is, is there an alternative? I've search for methods used before 'promise()` came in but couldn't find them, all I found was a plugin but I was thinking of something more simple.
No need to say I'm quite a JS noobie ^^. Any help much appreciated.