HTML闪烁文本颜色 [英] HTML flashing text colors

查看:237
本文介绍了HTML闪烁文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常不寻常的请求,但..

This is quite an unusual request, but..

有没有反正让一些文本每秒在两种颜色之间交替?

Is there anyway to make some text alternate between 2 colors every second?

所以它看起来好像它在说红色和灰色之间闪烁?我不是指背景颜色,我的意思是实际的字体颜色。我假设它需要javascript或某事。

So it appears as though it's flashing between say... red and grey? I don't mean background color, I mean the actual font color. I'm assuming it would need javascript or something.

有什么简单的方法吗?

Is there any simple way to do that?

(忽略可能看起来很丑的事实)

(disregarding the fact it could look ugly)

Id喜欢在我的页面上多次调用此函数,每次通过不同的颜色与GRAY

Id like to call to this function several times on my page, each one passing along a different color to alternate with GREY

交替。

推荐答案

根据您的要求:

    function flashtext(ele,col) {
    var tmpColCheck = document.getElementById( ele ).style.color;

      if (tmpColCheck === 'silver') {
        document.getElementById( ele ).style.color = col;
      } else {
        document.getElementById( ele ).style.color = 'silver';
      }
    } 

    setInterval(function() {
        flashtext('flashingtext','red');
        flashtext('flashingtext2','blue');
        flashtext('flashingtext3','green');
    }, 500 ); //set an interval timer up to repeat the function

JSFiddle这里:http://jsfiddle.net/neuroflux/rXVUh/14/

JSFiddle here: http://jsfiddle.net/neuroflux/rXVUh/14/

这篇关于HTML闪烁文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆