Input Search value Property
Example
Change the value of the search field:
document.getElementById("mySearch").value = "Favorite Cars";
Try it »
Definition and Usage
The value property sets or returns the value of the value attribute of the search field.
The value attribute describes the value entered by the user, the default value, or the value entered by a script.
Browser support





All major browsers support the value attribute
Syntax
Return the value attribute:
searchObject
.value
Set the value attribute:
searchObject
.value=
text
Attribute values
| Value | Description |
|---|---|
| text | Describes the initial (default) value of the search field. |
Technical Details
| Return Value: | A string representing the value of the search field |
|---|
More examples
Example
Get the value of the search field:
var x = document.getElementById("myRange").value;
x
The output is:
Food
Try it »
Related pages
HTML Reference Manual: HTML value attribute
Input Search Object