본문 바로가기

개발하자/자바스크립트

글자색 0.5초마다 변하기

<html>
 <head>
 <style type="text/css">
 font { font-size:10em; }
 </style>
 <script>
var array=["red","yellow","green"];
 var cnt=0;
 window.onload=function(){
 ff();
 }

 function ff(){
 if(cnt==3) cnt=0;
 f.style.color=array[cnt++];
 setTimeout("ff()",500);
 }
 </script>
 </head>
 <body>
 <font id="f">글자</font>
 </body>
</html>