JavaScript animations movement
<p>I am trying to make an animation in JavaScript, but there is an error i cannot find because my code won't work. I am trying to get the blue box to move diagonally from left to right but it just stays still. Please help.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function animate() {
  var elem = document.getElementById('ani');
  var pos = 0;
  var id = setInterval(frame, 3);

  function frame() {
    if (pos == 350) {
      clearInterval(id);
    } else {
      pos++;
      elem.style.top = pos + "px";
      elem.style.left = pos + "px";
    }
  }
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#box {
  background: red;
  width: 400px;
  height: 400px;
  position: relative;
}

#ani {
  background: blue;
  width: 50px;
  height: 50px;
  position: absolute;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
  &lt;link rel='stylesheet' href='style.css' /&gt;
  &lt;script src='script.js'&gt;&lt;/script&gt;
  &lt;title&gt;Practice&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;p&gt;
    &lt;button onclick="animate()"&gt;OK&lt;/button&gt;
  &lt;/p&gt;
  &lt;div id="box"&gt;
    &lt;div id="ani"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;</code></pre>
</div>
</div>
</p>