用JS實現變換背景和字體顏色
阿新 • • 發佈:2017-08-26
gree size out dex ext () func htm round
<!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>
用JS實現變換背景和字體顏色