yuwensong
<html>
    <head>
        <title>随机改变背景颜色(自动变化)</title>
        <style>
            #bg{
                width:200px;
                height:200px; 
            }
        </style>
    </head>
    <body>
        <div id="bg"></div>
        <script>
            function changeBg(){
                var bg=document.getElementById("bg");
                var rand=Math.round(Math.random()*1000000);
                bg.style.backgroundColor="#"+rand;
            }
            setInterval("changeBg();",1000);
        </script>
    </body>
</html>

 

分类:

技术点:

相关文章:

  • 2021-08-19
  • 2022-12-23
  • 2021-12-19
  • 2021-08-04
  • 2022-02-07
  • 2021-05-31
  • 2021-11-16
猜你喜欢
  • 2021-12-19
  • 2022-12-23
  • 2021-12-19
  • 2021-04-22
  • 2022-12-23
  • 2021-11-21
  • 2021-12-19
相关资源
相似解决方案