title: clearRect not working?
body: <p>I am a very beginner web designer and I have two questions about this code.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;style type="text/css"&gt;
  #canvas1{border: #666 3px solid;}
  &lt;/style&gt;
  &lt;script type="application/javascript" language="javascript"&gt;
  function draw (x,y){
  var canvas = document.getElementById('canvas1');
  var ctx = canvas.getContext('2d');
  ctx.save();
  ctx.clearRect(0, 0, canvas.width, canvas.height);
  ctx.fillstyle = "rgb (0,200, 0)";
  ctx.fillRect(x, 20, 50, 50);
  ctx.restore();
  x += 5;
  var loop = setTimeout('draw('+x+', '+y+')', 100); 
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;button onclick="draw(0,0)"&gt;Start&lt;/button&gt;
  &lt;canvas id="canvas1" width="400" height="400"&lt;/canvas&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Why does the block always turn out black? and Why if I try to press start again, the clearRect function doesn’t work?</p>