access child elements within dom - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

access child elements within dom

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from w  ww.  j  a  v  a2  s  . co m*/
nodes = document.getElementsByTagName('custom');
for (var i = 0; i< nodes.length; ++i) {
    paragraphs = nodes[i].getElementsByTagName('p');
    console.log(paragraphs[0].innerHTML);
    }
    }

      </script> 
   </head> 
   <body> 
      <custom> 
         <p>This is a text</p> 
      </custom>  
   </body>
</html>

Related Tutorials