title: Why is function being called without clicking on button?
body: <p>I am trying to move the smaller block 'onclick' of the button in html. But either it is not calling that function or may be it is calling it even before the button is clicked. How to find out and solve to get the required response?</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  var pos = 0;
  //getting box element
  var box = document.getElementById("box");
  var time = setInterval(move, 10);
  document.getElementById("btn1").onclick = move(){
      if(pos &gt;= 150){
          clearInterval(time);
      } else{
          pos += 1;
          box.style.left = pos+"px";
      }
  };
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;&lt;p id="p1" style="color:#dd3333"&gt;Sample Game&lt;/p&gt;&lt;/h1&gt;
  &lt;p id="p2" styel="color:#b5b5b5"&gt;Click on the button below&lt;/p&gt;
  &lt;style&gt;
  #container{
  width:200px;
  height:200px;
  background:green;
  position:relative;
  }
  #box{
  width:50px;
  height:50px;
  background:red;
  position:absolute;
  }
  &lt;/style&gt;
  &lt;div id="container"&gt;
  &lt;div id="box"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;br&gt;&lt;/br&gt;
  &lt;button id="btn1"&gt;Click Me&lt;/button&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>