Change the text of a search field:
The value property sets or returns the value of the value attribute of a search field.
The value attribute specifies the default value OR the value a user types in (or a value set by a script).
The value property is supported in all major browsers.
Return the value property:
Set the value property:
Value | Description |
---|---|
text | Specifies the value of the search field |
Return Value: | A String, representing the value of the search field |
---|
Get the text of a search field:
The result of x will be:
An example that shows the difference between the defaultValue and value property:
HTML reference: HTML <input> value attribute