zoukankan      html  css  js  c++  java
  • 用JS 写一个简单的程序,切换七彩盒子背景

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <title></title>

    <style type="text/css">

    .stage{

    width: 210px;

    height: 250px;

    margin: 50px auto;

    }

    #box{

    margin-top: 20px;

    width: 210px;

    height:210px;

    background: red;

    }

    </style>

    </head>

    <body>

    <div class="stage">

    <span>点击盒子变换颜色额!!</span>

    <div id="box" onclick="changecolor()"></div>

    </div>

    </body>

    <script type="text/javascript">

    var box=1;

    function changecolor(){

    var a=document.getElementById("box");

    switch(box){

    case 1:a.style.backgroundColor="yellow";box++;break;

    case 2:a.style.backgroundColor="cyan";box++;break;

    case 3:a.style.backgroundColor="tomato";box++;break;

    case 4:a.style.backgroundColor="purple";box++;break;

    case 5:a.style.backgroundColor="cornflowerblue";box++;break;

    case 6:a.style.backgroundColor="darksalmon";box++;break;

    case 7:a.style.backgroundColor="red";box=1;break;

    }

    }

    </script>

    </html>

  • 相关阅读:
    1320. Graph Decomposition 夜
    1156. Two Rounds 夜
    1176. Hyperchannels 夜
    1227. Rally Championship 夜
    1450. Russian Pipelines 夜
    1137. Bus Routes 夜
    找回c盘空间
    IDOC
    .落叶无痕水无声
    真正写的第一篇博客吧
  • 原文地址:https://www.cnblogs.com/niuniudashijie/p/5987941.html
Copyright © 2011-2022 走看看