通过javascript定时循环给字体设置颜色
var colortag = 0;
function getColor(){
colortag++;
switch(colortag){
case 1:return "#ff0000";
case 2:return "#ff6600";
case 3:return "#3366cc";
default:return "black";
}
}
function colorful(id){
o =document.getElementById(id);
//console.log(o);
o.style.color=getColor();
o.style.background="white";
if(colortag==3)colortag=0;
timer=setTimeout('colorful('+id+')',1000);
}
function stoptimer() {
o.style.color="white";
o.style.background="#3091f2";
clearTimeout(timer);
}
第一个是设置颜色,第二个是赋予这个标签颜色。第三个是关掉这个闪烁
有一个小细节,<a>这个标签,浏览器会自动赋予一个颜色,如果想让他继承上面父类的颜色,要用color:inherit