Input Text value Property - Javascript DOM HTML Element

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

Return Value

A String, representing the value of the text field

The following code shows how to change the value of a text field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
Name: <input type="text" id="myText" value="Mickey">

<button onclick="myFunction()">Test</button>

function myFunction() {/* ww  w. j  a  va  2  s . c o  m*/
    document.getElementById("myText").value = "new value";


Related Tutorials