title: Moving elements left and right in Javascript
body: <p>I'm trying to get an element to move in a random X and Y direction every second and every direction should be different for each element when a check box is clicked. </p>
  
  <p>The code I have so far is....</p>
  
  <pre><code> &lt;div id="exam" class="exam"&gt;
              Exam 1
              &lt;input type="button" id="copy" value="Make Copy" onclick="makeCopy()" /&gt;
              &lt;input type="button" id="array" value="Get Array" onclick="makeArray()" /&gt;
              &lt;input type="checkbox" id="moving" onclick="doMove()"&gt;Making Them Move!!
      &lt;/div&gt;
  
     &lt;script&gt;
       function doMove() {
              moving.style.left = (moving.style.left+10)+'px';
              setTimeout(doMove,1);
          }
     &lt;/script&gt;
  </code></pre>
  
  <p>This isn't working for me...Does anyone know how I can improve the function to make them move like I stated above?</p>
  
  <p>This is the code I have now....</p>
  
  <pre><code>    &lt;div id="exam" class="exam"&gt;
              Exam 1
              &lt;input type="button" id="copy" value="Make Copy" onclick="makeCopy()" /&gt;
              &lt;input type="button" id="array" value="Get Array" onclick="makeArray()" /&gt;
              &lt;input type="checkbox" id="moving" onclick="doMove()"&gt;Making Them Move!!
          &lt;/div&gt;
  &lt;script&gt;
              function doMove() {
                  var moving = document.getElementById("moving");
                  moving.style.left = (moving.style.left+10)+'px';
              }
              setTimeout(doMove,1000);
              &lt;/script&gt;
  </code></pre>