title: How ChildNode Works
body: <pre><code>&lt;html&gt;
    &lt;head&gt;
  
      &lt;title&gt;&lt;/title&gt;
      &lt;script type="text/javascript"&gt;&lt;!--
  function test2() {
    var val2 = document.getElementById("ex2").childNodes[1].childNodes[0].nodeValue;
    alert(val2);
  }
  --&gt;&lt;/script&gt;
  
    &lt;/head&gt;
    &lt;body&gt;
          &lt;div id="ex2"&gt;Web courses - &lt;span&gt;http://coursesweb.net&lt;/span&gt; - lessons, tutorials&lt;/div&gt;
  &lt;a href="#" onclick="test2()" title="childNodes example"&gt;Test 2&lt;/a&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Above alerts <a href="http://coursesweb.net" rel="nofollow">http://coursesweb.net</a>.</p>
  
  <p>But if i add <code>&lt;p&gt;Some text&lt;/p&gt;</code> and than i try to add <code>childNodes[2]</code> its not working.</p>
  
  <p>Can some one please explain me this code and <code>ChildNode</code> Concept too.</p>