title: Javascript: document.getElementById() returns NULL
body: <p>I am quite new with Javascript and I got a problem with document.getElementById() that always returns NULL, and that's driving me nuts.</p>
  
  <p>I have a  element in my code and I want to get its coordinates so I can move it.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;script type="text/javascript" &gt;
        function MoveIt(obj) {
          alert(obj); // returns "Object HTMLDivElement"
          var xx = document.getElementById("arect");
  
          if(document.getElementById("arect").value == null) {
            alert('NULL &gt;&gt; ' + xx.value);
          }
          else {
            alert('NOT NULL &gt;&gt;' + xx.value);
          }
  
          posX = xx.style.scrollTop;
          posY = xx.style.left;
        }
      &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body bgcolor="white" &gt;
      &lt;DIV class="background" id="MyDiv2"&gt;  
        &lt;div id="arect" name="arect" class="transbox" onmousedown="MoveIt(this);" &gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The above function MoveIt() always returns NULL</p>