我是新来的JavaScript,我需要改变文本的颜色在这个脚本:的Javascript水平滚动文本,改变颜色
<script language="javascript">
<!--
var bannerID=0
function text(msg,ctrlwidth) {
msg = " --- "+msg
newmsg = msg
while (newmsg.length < ctrlwidth) {
newmsg += msg
}
document.write ('<FORM NAME="Scrolltext">');
document.write ('<CENTER><INPUT NAME="text" VALUE= "'+newmsg+'" SIZE= '+ctrlwidth+' ></CENTER>');
document.write ('</FORM>');
var bannerID = null
rollmsg()
}
function rollmsg() {
NowMsg = document.Scrolltext.text.value
NowMsg = NowMsg.substring(1,NowMsg.length)+NowMsg.substring(0,1)
document.Scrolltext.text.value = NowMsg
bannerID = setTimeout("rollmsg()",100)//change the number 100 to represent the speed of the scroll. The larger the number the slower it moves
}
// -->
</script>
<script>
<!--
msg = " TEXT GOES HERE"
ctrlwidth = "100" //change this number to the length you would like the message box to be
text(msg,ctrlwidth);
// -->
</script>
当前的文本颜色是黑色的,它应该是白色。
它工作。谢谢。 – 2014-11-21 10:07:33
很高兴它有帮助,只要记住你必须使用'.style'来访问元素样式。 – 2014-11-21 10:09:25
会做。你有没有机会知道如何从左到右滚动?与其当前滚动方向相反 – 2014-11-21 11:47:35