Input Text placeholder Attribute
Definition and Usage
placeholder
Sets or returns the value of the placeholder attribute of the text field.
The HTML placeholder attribute specifies a brief hint that describes the expected value of the text field (for example, a sample value or a brief description of the expected format).
A short prompt will be 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 text field:
document.getElementById("myText").placeholder = "Type name here..";
Example 2
Get the placeholder text of the text field:
var x = document.getElementById("myText").placeholder;
Syntax
Return the placeholder attribute:
textObject.placeholder
Set the placeholder attribute:
textObject.placeholder = text
Attribute Value
Value | Description |
---|---|
text | Specifies a brief hint (word or phrase) for the expected value of the text field. |
Technical Details
Return Value: | A string value that represents a brief hint of the expected value of the text 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 |