1 <html> 2 <head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <title>变色</title> 5 </head> 6 7 <body> 8 9 <h1 id="actext">狄瑶</h1> 10 <script type="text/javascript"> 11 var i = 0; 12 function getColor(){ 13 i++; 14 switch(i){ 15 case 1:return "#ff0000"; 16 case 2:return "#FFCCDD"; 17 case 3:return "#3366cc"; 18 case 4:return "#FFDEAD"; 19 case 5:return "#EE30A7"; 20 case 6:return "#97FFFF"; 21 case 7:return "#00FF00"; 22 default:return "black"; 23 } 24 } 25 function colorful(){ 26 var o =document.getElementById(‘actext‘); 27 o.style.color=getColor(); 28 if(i==8)i=0; 29 setTimeout(‘colorful()‘,500); 30 } 31 colorful(); 32 </script> 33 </body> 34 </html>
时间: 2024-10-17 23:04:22