title: getElementByTagName() not working?
body: <ol>
  <li><p>In my page I've got 3 table elements, I want to access the 3rd  element using its tagname.</p>
  <p>So, I used <code>document.getElementByTagName(&quot;table&quot;)[2];</code></p>
  </li>
  <li><p>Later, I tried to obtain value of an element in that table by      <code>table.children[0].children[1].children[2].innerHTML;</code></p>
  </li>
  <li><p>Then, I tried to modify the already existing <code>&lt;p&gt;</code>element with   <code>id=&quot;ID&quot;</code> .</p>
  <p>But I'm not getting the value modified?</p>
  </li>
  </ol>
  <p><strong>Whats wrong with my script?</strong></p>
  <pre><code>&lt;!DOCTYPE HTML&gt;
  
  &lt;html&gt;
    &lt;body&gt;
      ID  : &lt;p id=&quot;ID&quot;&gt;&lt;/p&gt;
   &lt;body&gt;
  &lt;table&gt;
    
  &lt;/table&gt;
  &lt;table&gt;
    
  &lt;/table&gt;
  
  &lt;table&gt;
    &lt;tbody&gt;
    &lt;tr&gt;
    
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Name&lt;/td&gt;
      &lt;td&gt;Class&lt;/td&gt;
      &lt;td&gt;25&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    
    &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;script&gt;
  
  var table = document.getElementByTagName(&quot;table&quot;)[2];
   var id = table.children[0].children[1].children[2].innerHTML;
   
  document.getElementById(&quot;ID&quot;).innerHTML = id;
      
      &lt;/script&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>