Input Text placeholder Property

Input Text 对象参考手册Input Text Object

Examples

Modify the placeholder text of the text field:

document.getElementById("myText").placeholder = "Enter name here..";

Try it Yourself »


Definition and Usage

The placeholder property is used to set or return the value of the placeholder property of a text field.

The placeholder property specifies the hint information for the expected value of an input field.

This hint is displayed when the input field is empty, and disappears when the field receives focus.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the placeholder property.

Note:Internet Explorer 9 and earlier IE versions do not support the placeholder property.


Syntax

Return the placeholder property:

textObject.placeholder

Set the placeholder property:

textObject.placeholder=text

Property Values

Value Description
text Specifies a short hint (a word or phrase) used to describe the expected value of the text field.
Technical Details
Return Value: A string, a short hint used to describe the expected value of the text field.


More Examples

Example

Get the hint information of the text field:

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

xThe output result is:

Name

Try it Yourself »


Related Pages

HTML Reference:HTML <input> placeholder Property


Input Text 对象参考手册Input Text Object Other Extensions