InnerText vs textContent on an element - Javascript DOM

Javascript examples for DOM:Element innerText

Description

InnerText vs textContent on an element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
var textContent = ('textContent' in document) ? 'textContent' : 'innerText';
window.onload = function () {// w w w.ja va 2  s.  c om
    console.log(document.getElementById('test')[textContent]);
}

      </script> 
   </head> 
   <body> 
      <div id="test">
         Test
      </div>  
   </body>
</html>

Related Tutorials