三个按钮 点击可变三种颜色

 

 

<html>
  <head>
  <meta charset="utf-8">
    <meta name="generator"
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
    <title></title>
    <style>
    #div1{
    width:100px;
    height:100px;
    background:red;
    }
    </style>
    <script>
    function toYellow(){
      var oDiv=document.getElementById('div1');
      oDiv.style.background='yellow';
    }
    
    function toGreen(){
      var oDiv=document.getElementById('div1');
      oDiv.style.background='green';
    }
    function toBlue(){
      var oDiv=document.getElementById('div1');
      oDiv.style.background='blue';
    }
    </script>
  </head>
  <body>
  <input type="button" value="变黄" onclick="toYellow()"/>
  <input type="button" value="变绿" onclick="toGreen()"/>
  <input type="button" value="变蓝" onclick="toBlue()"/>
  <div id="div1"></div>
  </body>
</html>

 

posted @ 2016-09-30 18:15  缘琪梦  阅读(484)  评论(0编辑  收藏  举报