<!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.5.1/jquery.min.js"></script> <script> //setTimeout var colors = new Array("red","green","blue"); function changeColor(){ //var colorIndex = Math.round(Math.random()*3); var color_div=colors[Math.round(Math.random()*3)]; var color_font=colors[Math.round(Math.random()*3)]; document.getElementById("div_c").style.background=color_div; document.getElementById("font_c").style.color=color_font; //document.wirte(colorIndex); setTimeout("changeColor()",1000); } </script> </head> <body onload="changeColor()"> <div id="div_c" align="center" style="height:1000px;width:100%"> <br/> <br/> <br/> <font id="font_c" size="20px" >自动变换颜色</font> </div> </body> </html>
时间: 2024-10-01 02:28:05