1

我刚刚在另一个线程中找到了这个演示,但想问一下我是否有机会改变旋转文本的颜色,我正在玩,但无法弄清楚,任何帮助都是请欣赏

工作演示

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);
4

2 回答 2

1

只需使用另一个数组来保存颜色,然后使用.css()

这是一个工作版本...

http://jsfiddle.net/zqEmT/11/

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);
于 2013-02-11T14:38:42.280 回答
0

试试这个,它应该让你开始:

http://jsfiddle.net/zqEmT/9/

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);
于 2013-02-11T14:38:24.053 回答