Javascript examples for DOM HTML Element:Input Text
The value property sets or gets the value attribute of a text field.
Set the value property with the following Values
Value | Description |
---|---|
text | Sets the value of the input text field |
A String, representing the value of the text field
The following code shows how to change the value of a text field:
<!DOCTYPE html> <html> <body> Name: <input type="text" id="myText" value="Mickey"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* ww w. j a va 2 s . c o m*/ document.getElementById("myText").value = "new value"; } </script> </body> </html>