我是新來的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