title: Inserting a Div Into another Div?
body: <p>Im creating a web app and would like to know why the following code is not working. It first creates a  element which is then added to the body. I then create another Div element which i would like to place inside the first div element that i created.</p>
  
  <p>Im using MooTools classes to create and initialize objects and it works fine but i just cant seem to get the following code to work. The code is inside an<code>initialize: function()</code> of a class:</p>
  
  <pre><code>this.mainAppDiv = document.createElement("div");
  this.mainAppDiv.id = "mainBody";
  this.mainAppDiv.style.width = "100%";
  this.mainAppDiv.style.height = "80%";
  this.mainAppDiv.style.border = "thin red dashed";
  document.body.appendChild(this.mainAppDiv); //Inserted the div into &lt;body&gt;
  //----------------------------------------------------//
  this.mainCanvasDiv = document.createElement("div");
  this.mainCanvasDiv.id = "mainCanvas";
  this.mainCanvasDiv.style.width = "600px";
  this.mainCanvasDiv.style.height = "400px";
  this.mainCanvasDiv.style.border = "thin black solid";
  document.getElementById(this.mainAppDiv.id).appendChild(this.mainCanvasDiv.id);
  </code></pre>
  
  <p>As you can see it first creates a div called "mainBody" and then appends it the document.body, This part of the code works fine. The problem comes from then creating the second div and trying to insert that using<code>document.getElementById(this.mainAppDiv.id).i(this.mainCanvasDiv.id);</code></p>
  
  <p>Can anyone think of a reason the above code does not work?</p>