title: appendChild method is not defined when using with a div element
body: <p>I'm really a beginner in Javascript and trying to add a <code>p</code> element inside a <code>div</code> element in this HTML :</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;p&gt;This is paragraph 1.&lt;/p&gt;
          &lt;p&gt;This is paragraph 2.&lt;/p&gt;
          &lt;p&gt;This is paragraph 3.&lt;/p&gt;
          &lt;p&gt;This is paragraph 4.&lt;/p&gt;
          &lt;div&gt;
              &lt;p id="foo"&gt;This is paragraph 5.&lt;/p&gt;
          &lt;/div&gt;
          &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>using this code : </p>
  
  <pre><code>(function(){
      var divElement = document.getElementsByTagName("div");
          el = document.createElement("p");
          content = document.createTextNode("This is text");    
      el.appendChild(content);
      document.divElement.appendChild(el);        
  }());
  </code></pre>
  
  <p>But i get this error at line 6 : </p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot call method 'appendChild' of undefined</p>
  </blockquote>