title: Why is appendChild not working?
body: <p>I’m trying to create three elements (parent, and one child) but the third element which is an <code>&lt;a&gt;</code> tag is not appending to <code>modalChild</code> event thought it’s creating it correctly.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>modal = document.createElement("div");
      modal.className = "parent";
   modalChild = document.createElement("div");
   modalChild.className = "child";
      btnClose = document.createElement("a");
   btnClose.className = "btnClose";
   btnClose.textContent = "X";
  
   modal.appendChild(modalChild);
   modalChild.appendChild(btnClose);
  
   document.body.appendChild(modal);
   modal.style.display = "flex";</code></pre>
  </div>
  </div>
  </p>
  
  <p><code>modalChild</code> is being appended to modal correctly but <code>btnClose</code> is not appending to <code>modalChild</code>. Does anyone see the problem with the code?</p>