Getting link text within a div - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Getting link text within a div

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() {//ww  w.j ava  2 s .  c o m
console.log(document.getElementsByClassName('myClass')[0].childNodes[1].innerHTML);
    });

      </script> 
   </head> 
   <body> 
      <div id="myDiv"> 
         <h1 class="myClass"> 
            <a href="link">TEXT</a> 
         </h1> 
      </div>  
   </body>
</html>

Related Tutorials