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