How can I change a word every 2-3 seconds using jQuery?
For example:
I have this:
This is so
<
This should work. First, add an id to the span that you want to rotate the text on. E.g.,
awesome
And in your JavaScript:
$(function() {
var words = ['cool', 'fantastic', 'incredible', 'awesome'],
index = 0,
$el = $('#rotate-word')
setInterval(function() {
index++ < words.length - 1 || (index = 0);
$el.fadeOut(function() {
$el.text(words[index]).fadeIn();
});
}, 3000);
});
You can see this in action here: http://jsfiddle.net/DMeEk/