HTML DOM Input Text Object
snippet in html

HTML DOM Input Text Object

user594

<!DOCTYPE html>
<html>
<body>

<input type="text" id="myText" value="Here is were your Text Input goes">

<button onclick="myFunction()">Try it</button>

<p id="output"></p>

<script>
function myFunction() {
  var x = document.getElementById("myText").value;
  document.getElementById("output").innerHTML = x;
}
</script>

</body>
</html>

add an input DOM

user4513

<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        HTML DOM Input Text Object 
    </title> 
</head>    
  
<body>  
  
    <h1>GeeksForGeeks</h1>  
  
    <h2>DOM Input Text Object</h2> 
  
    <input type="text" id="text_id" value="Hello Geeks!"> 
      
    <p>Click on button to display the text field</p> 
      
    <button onclick="myGeeks()">Click Here!</button> 
      
    <p id="GFG"></p> 
      
    <!-- script to access text field -->
    <script> 
        function myGeeks() { 
            var txt = document.getElementById("text_id").value; 
            document.getElementById("GFG").innerHTML = txt; 
        } 
    </script> 
</body> 
  
</html>