Easy Tutorial
❮ Prop Html Dir Jsref Log10E ❯

Textarea placeholder Attribute

Textarea Object


Example

Modify the placeholder (expected value) attribute of a textarea:

document.getElementById("myTextarea").placeholder = "Enter search keywords...";

Definition and Usage

The placeholder attribute is used to set or return the value of the placeholder attribute of a textarea element.

The placeholder attribute specifies a short hint that describes the expected value of a textarea element.

The placeholder is displayed in the textarea element when the value is empty and disappears when the textarea element gets focus.


Browser Support

Attribute Chrome IE Firefox Safari Opera
placeholder Yes 10.0 Yes Yes Yes

Syntax

Return the placeholder attribute:

textareaObject.placeholder

Set the placeholder attribute:

textareaObject.placeholder = text

Attribute Values

Value Description
text A string representing the expected value of the textarea element.

Technical Details

| Return Value: | A string, the expected value of the textarea element. |


More Examples

Example

Get the placeholder (expected value) attribute value of a textarea:

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

Textarea Object

❮ Prop Html Dir Jsref Log10E ❯