Get value of HTML element in javascript via innerHTML - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Get value of HTML element in javascript via innerHTML

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  w w .  ja v  a 2s.  c  om*/
var value = document.getElementById("theInput").innerHTML;
console.log(value);
    }

      </script> 
   </head> 
   <body> 
      <p id="theInput"> desired-value </p>  
   </body>
</html>

Related Tutorials