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

Input Search placeholder Property

Input Search Object Reference Input Search Object

Example

Change the placeholder text of a search field:

document.getElementById("mySearch").placeholder = "Search files";

Try it yourself »


Definition and Usage

The placeholder property sets or returns the value of the placeholder attribute of a search field.

The placeholder attribute specifies a short hint that describes the expected value of a search field (e.g. a sample value or a short description of the expected format).

The short hint is displayed in the text field before the user enters a value.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The placeholder property is supported in all major browsers.

Note: The placeholder property is not supported in Internet Explorer 9 and earlier versions.


Syntax

Return the placeholder property:

searchObject.placeholder

Set the placeholder property:

searchObject.placeholder=text

Property Values

Value Description
text Specifies a short hint (one word or a short phrase) that describes the expected value of the search field

Technical Details

Return Value: A String, representing a short hint that describes the expected value of the search field


More Examples

Example

Get the placeholder text of a search field:

var x = document.getElementById("mySearch").placeholder;

The result of x will be:

Name

Try it yourself »


Related Pages

HTML reference: HTML <input> placeholder 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 BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook