Input Search placeholder Attribute
Definition and Usage
placeholder
Sets or returns the value of the placeholder attribute of the search field.
The HTML placeholder attribute specifies a brief hint that describes the expected value of the search field (for example, a sample value or a brief description of the expected format).
A short hint is displayed in the text field before the user enters a value.
See also:
HTML Reference Manual:HTML <input> placeholder Attribute
Example
Example 1
Change the placeholder text of the search field:
document.getElementById("mySearch").placeholder = "Search Image";
Example 2
Get the placeholder text of the search field:
var x = document.getElementById("mySearch").placeholder;
Syntax
Return the placeholder attribute:
searchObject.placeholder
Set the placeholder attribute:
searchObject.placeholder = text
Attribute Value
Value | Description |
---|---|
text | Specifies a brief hint (word or phrase) describing the expected value of the search field. |
Technical Details
Return Value: | A string value that represents a brief hint describing the expected value of the search field. |
---|
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |