How can I change a word every 2-3 seconds using jQuery?
For example:
I have this:
This is so
<
$(document).ready(function(){
setInterval(function(){
var current = jQuery(".animate-span .active");
var cIndex = jQuery(".animate-span span").index(current), cLength = jQuery(".animate-span span").length, nextSpan = null;
if(cIndex<(cLength-1)){
nextSpan = jQuery(".animate-span span").eq(cIndex+1)
}else{
nextSpan = jQuery(".animate-span span").eq(0);
}
nextSpan.animate({top:0,opacity:1},500).addClass("active");
current.animate({top:45,opacity:0},500,function(){
jQuery(this).css({top:-40});
}).removeClass("active");
},2000)
});
live demo here