Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Text placeholder property

Input Text placeholder property

Input Text Object Reference The Input Text object

Example

Modify the placeholder text of the text field:

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

Try it »


Definition and Usage

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

The placeholder property tracks the hint information of the expected value of the input field.

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


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the placeholder property.

Note: Browsers of 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

Attribute values

Value Description
text Specifies a brief hint (a word or phrase) used to describe the expected value of the text field

Technical Details

Return Value: String, a brief 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;

x The output is:

Name

Try it »


Related pages

HTML Reference Manual: HTML placeholder property


Input Text Object Reference The Input Text object