X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input Search value Property

Input Search Object Reference Input Search Object

Example

Change the text of a search field:

document.getElementById("mySearch").value = "Favorite Cars";

Try it yourself »


Definition and Usage

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

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Syntax

Return the value property:

searchObject.value

Set the value property:

searchObject.value=text

Property Values

Value Description
text Specifies the initial (default) value of the search field

Technical Details

Return Value: A String, representing the default value of the search field


More Examples

Example

Get the text of a search field:

var x = document.getElementById("mySeach").value;

The result of x will be:

50

Try it yourself »


Related Pages

HTML reference: HTML <input> value attribute


Input Search Object Reference Input Search Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook