<!doctype html>
<style>
  body {
    margin: 0;
    padding: 0;
  }

  #box {
    background: red;
    position: absolute;
    top: 0;
    left: 0;
    width: 100px;
    height: 100px;
  }

  #box.green {
    background: green;
  }

  #box.blue {
    background: blue;
  }
</style>
<body>
  <div id="box" onclick="setColor('green');" ondblclick="setColor('blue');"></div>
  <script>
    function setColor(c) {
      document.getElementById('box').className = c
    }
  </script>
</body>
