Textarea placeholder Property
Example
Change the placeholder text of a text area:
document.getElementById("myTextarea").placeholder = "Where do
you live?";
Try it yourself »
Definition and Usage
The placeholder property sets or returns the value of the placeholder attribute of a text area.
The placeholder attribute specifies a short hint that describes the expected value of a text area (e.g. a sample value or a short description of the expected format).
The hint is displayed in the text area when it is empty, and disappears when the field gets focus.
Browser Support
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:
textareaObject.placeholder
Set the placeholder property:
textareaObject.placeholder=text
Property Values
Value | Description |
---|---|
text | Specifies a short hint (one word or a short phrase) that describes the expected value of the text area |
Technical Details
Return Value: | A String, representing a short hint that describes the expected value of the text area |
---|
More Examples
Example
Get the placeholder text of a text area:
var x = document.getElementById("myTextarea").placeholder;
The result of x will be:
Your address..
Try it yourself »
Related Pages
HTML reference: HTML <textarea> placeholder attribute
Textarea Object