Javascript – HTML flashing text colors


This is quite an unusual request, but..

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

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 like to call to this function several times on my page, each one passing along a different color to alternate with GREY


Best Solution

As per your request:

    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() {
    }, 500 ); //set an interval timer up to repeat the function

JSFiddle here:

Related Question