title: Failed to execute 'appendChild' on 'Node': The new child element is null
body: <p>This weird bug is bugging me from half an hour. I am dynamically trying to apply a slider using only JavaScript. Any idea as to why this is occurring to me? I could find other questions on SO, but could not understand the solution. I am new to JS and highly appreciate if someone could explain me things in laymen terms. Here is my code.  </p>
  
  <p><strong>MARKUP</strong>  </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
      &lt;title&gt;JS sample test page&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="jquery.bxslider.css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div class="og-fullimg"&gt;&lt;/div&gt;
      &lt;script type="text/javascript" src="jquery-1.11.1.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="jquery.bxslider.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="main.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;  
  </code></pre>
  
  <p><strong>JAVASCRIPT</strong>  </p>
  
  <pre><code>// code for thumbnail slider begins
  (function() {
      var ogImg = document.getElementsByClassName("og-fullimg");
      alert(ogImg.length);
      var bxSlider = document.createElement("ul"); //created ul
      bxSlider.setAttribute("class", "bxslider"); // gave a class name bxslider.
  
      for (i = 1; i &lt; 4; i++) {
          var itemsList = document.createElement("li");
          var linkImages = document.createElement("img");
          linkImages.src = "images/bid_" + i + ".jpg";
          itemsList.appendChild(linkImages);
          bxSlider.appendChild(itemsList);
      }
  
      ogImg[0].appendChild(bxSlider);
      document.body.appendChild(ogImg); //append everything to the body.
  
  
      //call the slider.
      $(document).ready(function() {
          $('.bxslider').bxSlider({
              auto: true,
              pager: false,
              adaptiveHeight: true,
              slideWidth: 550
          });
      });
  
  }());
  // code for thumbnail slider ends.  
  </code></pre>
  
  <p>Thanks in advance.</p>