1

我想改变我的选框颜色这是 Html 代码

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

这是javascript代码

<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>

您也可以通过访问此链接来访问它:http: //jsfiddle.net/W4tzf/

4

2 回答 2

6

下面的代码有效。正如其他人提到的,你拼错了document. 实现你想要的最简单的方法是使用setInterval, 和不带引号的函数名。

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);
于 2013-08-03T23:10:04.837 回答
3

你拼错了“document”,而是写了“documrnt”。

于 2013-08-03T23:10:03.090 回答