title: JavaScript insert div
body: <p>I'm attempting to insert a div before the "add div" button. I'm receiving an node not found error with this code:</p>
  
  <pre><code>document.getElementById("reg").insertBefore(newField, document.getElementById("op"));
  </code></pre>
  
  <p>But this code works, even though it's not the result I want:</p>
  
  <pre><code>document.getElementById("reg").insertBefore(newField, document.getElementById("op").parentNode);
  </code></pre>
  
  <p>Here's the source:</p>
  
  <pre><code>&lt;form id="reg"&gt;
    &lt;div class="section"&gt;
      &lt;div class="sectionHeader"&gt;Welcome&lt;/div&gt;
      &lt;div id="op1"&gt;
        &lt;div class="split25"&gt;
          &lt;select&gt;&lt;/select&gt;
        &lt;/div&gt;
        &lt;div class="split25"&gt;
          &lt;select&gt;&lt;/select&gt;
        &lt;/div&gt;
        &lt;div class="split50"&gt;
          &lt;input&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="additional" id="op"&gt;&lt;button&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;form&gt;
  </code></pre>
  
  <p>Why can it access its parent node but not itself?</p>