title: Javascript createElement
body: <p>I need a quick help setting up the createElement, which is the following:</p>
  
  <pre><code>&lt;h1 class="headingTitle"&gt; ENDANGERED &lt;span class="subHeading"&gt;Animals&lt;/span&gt; &lt;/h1&gt;
  </code></pre>
  
  <p>I have made this but it produced an error, which is this:</p>
  
  <blockquote>
    <p>Uncaught Error: NotFoundError: DOM Exception 8 </p>
  </blockquote>
  
  <pre><code>//Adds 'containr' div to the body
  var containerElement = document.createElement('div');
  containerElement.setAttribute('class','container');
  document.body.appendChild(containerElement);
  
  //Add the ENDANGERED ANIMALS title
  var title = document.createElement("h1");
  title.setAttribute('class', 'headingTitle');
  var text = document.createTextNode("ENDANGERED");
  
  var span = document.createElement('span');
  span.setAttribute('class', 'subHeading');
  var subText = document.createTextNode("Animals");
  span.appendChild(title);
  title.appendChild(text);
  
  document.getElementsByClassName('container')[0].appendChild(title);
  </code></pre>