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
2 Answers
Reset to default 6The 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
版权声明:本文标题:javascript - how to change color dynamically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741295817a2370811.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论