Javascript examples for DOM HTML Element:Input Text
The Input Text object represents an HTML <input> element with type="text".
You can access an <input> element with type="text" by using getElementById():
<!DOCTYPE html> <html> <body> <input type="text" id="myText" value="Some text..."> <button onclick="myFunction()">get the text in the text field</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j a v a 2 s . c om var x = document.getElementById("myText").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>