zoukankan      html  css  js  c++  java
  • js生成随机颜色

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Document</title>
     6 </head>
     7 <style>
     8     #demo{
     9          600px;
    10         height: 600px;
    11     }
    12 </style>
    13 <body>
    14     <div id="demo"></div>
    15 <script>
    16     var div = document.getElementById("demo");
    17     randomColor(div);
    18     function randomColor(div) {
    19         r = Math.ceil(Math.random()*255);
    20         g = Math.ceil(Math.random()*255);
    21         b = Math.ceil(Math.random()*255);
    22         a = (Math.random()).toFixed(1);
    23         div.style.background = "rgb(" + r + "," + g + "," + b + "," + a + ")";
    24 }
    25 </script>
    26 </body>
    27 </html>
  • 相关阅读:
    练习三
    练习四
    练习二
    软件生命周期
    练习一 第六题
    练习一 第五题
    练习一 第四题
    练习一 第三题
    练习一 第二题
    AngularJs模块
  • 原文地址:https://www.cnblogs.com/XTheodore/p/12155306.html
Copyright © 2011-2022 走看看