<script>
var a=new Array("red","yellow","blue")
var i=0;
function t()
{
if(i>2) i=0
document.all.mxh.style.backgroundColor=a[i]
i++
setTimeout('t()',1000)
}
</script>
<input type=button id=mxh value=button style="background-color:gray" onclick="t()">
var a=new Array("red","yellow","blue")
var i=0;
function t()
{
if(i>2) i=0
document.all.mxh.style.backgroundColor=a[i]
i++
setTimeout('t()',1000)
}
</script>
<input type=button id=mxh value=button style="background-color:gray" onclick="t()">
<script>
var index = 0;
function changecolor(){
var a = new Array('red','green','yellow');
button.style.backgroundColor=a[index++];
if(index==3)
index=0;
}
</script>
ps:如果想提高鼠标的响应速度最好还是使用onmouseup.
例如:button现在为红色,点击一下,变为青色,再点击一下,变为黄色,再点击一下又变为红色,这样循环。
对不起,我没有表达清楚我的意思,请指点我。谢谢。
var a=new Array("red","yellow","blue")
var i=0;
function t()
{
if(i>2) i=0
document.all.mxh.style.backgroundColor=a[i]
i++
}
</script>
<input type=button id=mxh value=button style="background-color:gray" onclick="t()">