タイプライター効果

1759 ワード




    
        
        
    
    
    
        
        
        <h1 id="a"/>

        <script>
                
                var matha = 50;
                var txt =  "      、    ,    、    ,C/C++、java、php    ,        ,    20  ,    4   ,        ,        。    、    ,     100     ,      5     ,     、   ,     、  PM,    。         ,          ,            ,          ,            ,              ,         。";
                
                var a  = document.getElementById("a");
                
                function tim(){
                    var s = txt.split("");
                    
                    var length = s.length;
                    var i  = 0;
                
                    setInterval(function(){
                        if(i<length)
                        {   var tem  = s[i++];
                        
                            a.innerHTML+=tem;
                            a.style.color=getColor();
                            //document.body.style.backgroundColor=getColor();
                        }
                    },matha)
                }
                
                function getColor(){
                    var RED=parseInt(Math.random()*255)+1;
                    var GREEN=parseInt(Math.random()*255)+1;
                    var BLUE=parseInt(Math.random()*255)+1;
                    
                    return "rgb("+RED+","+GREEN+","+BLUE+")";
                }
                
                tim();
        </script>
    


</code></pre> 
</article>
                            </div>
                        </div>