Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Search value Property

Input Search value Property

Input Search Object Reference Input Search Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Input Search Object