Access child node's node value - Javascript DOM

Javascript examples for DOM:Element childNodes

Description

Access child node's node value

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <div id="intro"> 
         <h1>DOM Lesson one</h1> 
         <p>Hello world!</p> 
      </div> 
      <script>
try//from   www  .ja  va 2s  .c om
{
   console.log(document.getElementById("intro").childNodes);
   var txt=document.getElementById("intro").childNodes[1].nodeValue;
   document.write(txt);
}
catch(err)
{
   console.log(err);
}

      </script>  
   </body>
</html>

Related Tutorials