Loading
0

酷炫:让网页中的文字随机变换颜色

技术小学生微信公众号
腾讯云服务器大促销。
华为服务器
酷炫:让网页中的文字随机变换颜色

 
<body>
        <h1 id="color1" style="margin-top:100px">这里的文字会变颜色哦,blog.tag.gg</h1>
        <h1 id="color3" style="margin-top:100px"><a href="https://blog.tag.gg/" target="_blank">这里的文字会变颜色哦,blog.tag.gg</a></h1>

 
        <script>
            function randomHexColor() { //随机生成十六进制颜色
                        return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).substr(-6);
                }
                function color_rand()
                {
                        var color1 = document.getElementById('color1');
                        var color2 = document.getElementById('color2');
                        var color3 = document.getElementById('color3');
                        var color4 = document.getElementById('color4');
                        var color_href = document.getElementById('color_href');
                        var color_href2 = document.getElementById('color_href2');
                        
                        var Interval = setInterval(function(){
                                color1.style.color = randomHexColor();
                                color2.style.color = randomHexColor();
                                var a3 = randomHexColor();
                                color3.style.color = a3;
                                color_href.style.color = a3;
                                var a4 = randomHexColor();
                                color4.style.color = a4;
                                color_href2.style.color = a4;
                        },200);
                }
                setTimeout('color_rand()',1000);
        </script>
</body>

 

技术小学生微信公众号
华为服务器
腾讯云服务器大促销。

声明:站长码字很辛苦啊,转载时请保留本声明及附带文章链接:https://blog.tag.gg/showinfo-20-423-0.html
亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?

最后编辑于:2019-01-26 22:22:05作者:

上一篇:Zblog/Nginx给目录添加反斜杠的伪静态规则方法
下一篇:破解火车头发布模块wpm密码方法