Input Search placeholder Property

❮ Input Search Object

Example

Change the placeholder text of a search field:

document.getElementById("mySearch").placeholder = "Search files";
Try it Yourself »

Description

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

The numbers in the table specify the first browser version that fully supports the property.

Property
placeholder Yes 10.0 Yes Yes Yes

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;
Try it Yourself »

Related Pages

HTML reference: HTML <input> placeholder attribute


❮ Input Search Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.