admin管理员组

文章数量:1278882

I want to change my marquee color Here is Html code

<marquee><div id="thakan">Thakaan ka Ant, Shakti Turant!!</div></marquee>

And this is the javascript code

<script language="javascript" type="text/javascript">
var col=0;
function changeMarqueeColor()
{
    if(col==0)
    {
        //document.getElementById("p2").style.color="blue";
        documrnt.getElementById("thakan").style.color="yello";
        col=1;
    }
    else
    {
        documrnt.getElementById("thakan").style.color="blue";
        col=0;
    }

}
 b=setInterval("changeMarqueeColor();",500);
</script>

You can access this also by visiting this link : /

I want to change my marquee color Here is Html code

<marquee><div id="thakan">Thakaan ka Ant, Shakti Turant!!</div></marquee>

And this is the javascript code

<script language="javascript" type="text/javascript">
var col=0;
function changeMarqueeColor()
{
    if(col==0)
    {
        //document.getElementById("p2").style.color="blue";
        documrnt.getElementById("thakan").style.color="yello";
        col=1;
    }
    else
    {
        documrnt.getElementById("thakan").style.color="blue";
        col=0;
    }

}
 b=setInterval("changeMarqueeColor();",500);
</script>

You can access this also by visiting this link : http://jsfiddle/W4tzf/

Share Improve this question asked Aug 3, 2013 at 23:05 Ahmad AsjadAhmad Asjad 8231 gold badge9 silver badges30 bronze badges 3
  • ''document'' not ''documrnt'' shoud do the trick. – matiasf Commented Aug 3, 2013 at 23:07
  • Look at your console before asking a question. – Blender Commented Aug 3, 2013 at 23:08
  • 3 Wow marquee is still alive? – elclanrs Commented Aug 3, 2013 at 23:08
Add a ment  | 

2 Answers 2

Reset to default 6

The code below works. As others have mentioned, you've misspelled document. Also the simplest way to achieve what you want is with setInterval, and unquoted function name.

var col=0;
function changeMarqueeColor() 
{
    if(col==0)
    {
        document.getElementById("thakan").style.color="red";
        col=1;
    }
    else
    {
        document.getElementById("thakan").style.color="blue";
        col=0;
    }
}
setInterval(changeMarqueeColor,500);

You misspelled "document", you wrote "documrnt" instead.

本文标签: javascripthow to change color dynamicallyStack Overflow