Input Search value Property
Example
Change the text of a search field:
document.getElementById("mySearch").value = "Favorite Cars";
Try it Yourself »
Description
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).
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the value property:
searchObject.value
Set the value property:
searchObject.value = text
Property Values
Value | Description |
---|---|
text | Specifies the value of the search field |
Technical Details
Return Value: | A String, representing the value of the search field |
---|
More Examples
Example
Get the text of a search field:
var x = document.getElementById("mySeach").value;
Try it Yourself »
Example
An example that shows the difference between the defaultValue and value property:
var x = document.getElementById("mySearch");
var defaultVal = x.defaultValue;
var currentVal = x.value;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
❮ Input Search Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.