如何使用jQuery每2-3秒更改一个单词?
例如:
我有这个:
<div>
<span>This is so</span>
<span>awesome</span>
</div>
Run Code Online (Sandbox Code Playgroud)
...我希望真棒变成酷,梦幻,令人难以置信,并使用fadeOut/fadeIn效果保持循环循环可能吗?
可能吗?
非常感谢
Pau*_*aul 20
(function(){
// List your words here:
var words = [
'awesome',
'incredible',
'cool',
'fantastic'
], i = 0;
setInterval(function(){
$('#changerificwordspanid').fadeOut(function(){
$(this).html(words[i=(i+1)%words.length]).fadeIn();
});
// 2 seconds
}, 2000);
})();
Run Code Online (Sandbox Code Playgroud)
为您的span添加id,并更改changerificwordspanid为span的id .