title: My javascript alert dialog box appears empty. What is the reason?
body: <p>The result of alert dialog comes up empty. I am not able to access the parent of parent node</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>var bt = document.getElementById("btn1");
  bt.onclick = function() {
    alert(bt.parentNode.parentNode.className);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;head&gt;&lt;/head&gt;
  
  &lt;body&gt;
    &lt;div class="container"&gt;
      &lt;div class="template"&gt;
        &lt;div class="img "&gt; &lt;img src="images/demo/hotel1.jpg"&gt; &lt;/div&gt;
        &lt;div class="hname animated slideInRight"&gt;
          &lt;h2&gt;Golden Tulip &lt;span id="city"&gt;Lucknow&lt;/span&gt;&lt;/h2&gt;
        &lt;/div&gt;
        &lt;div class="address animated slideInLeft animated slideInLeft"&gt; &lt;span id="city"&gt;&lt;b&gt;Lucknow,&lt;b&gt;&lt;/span&gt; 2km to city centre. &lt;button id="btn1"&gt;View Deal&lt;/button&gt; &lt;/div&gt;
        &lt;div class="rating"&gt; 5 star &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>