我刚刚在另一个帖子中找到了这个演示,但是想问一下我是否有机会改变旋转文本的颜色,我正在玩弄但是无法弄明白,任何请帮助
工作demo
var keywords = ["awesome", "cool", "fantastic", "incredible"];
var count = 1;
setInterval(function(){
$("span.keyword").fadeOut(400, function(){
$(this).html(keywords[count]);
count++;
if(count == keywords.length)
count = 0;
$(this).fadeIn(400);
});
}, 2000);
答案 0 :(得分:1)
只需使用其他数组来保存颜色,然后使用.css()
这是一个有效的版本......
var keywords = ["awesome", "cool", "fantastic", "incredible"];
var colours = ["red", "green", "blue", "orange"];
var count = 1;
setInterval(function(){
$("span.keyword").fadeOut(400, function(){
$(this).html(keywords[count]).css("color", colours[count]);
count++;
if(count == keywords.length)
count = 0;
$(this).fadeIn(400);
});
}, 2000);
答案 1 :(得分:0)
试试这个,它应该让你开始:
var keywords = ["awesome", "cool", "fantastic", "incredible"];
var count = 1;
setInterval(function(){
$("span.keyword").fadeOut(400, function(){
$(this).html(keywords[count]);
count++;
if(count == keywords.length)
count = 0;
var hue = 'rgb('
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ','
+ (Math.floor(Math.random() * 256)) + ')';
$(this).fadeIn(400).css('color', hue);
});
}, 2000);