Easy Tutorial
❮ Event Onloadstart Met Node Isequalnode ❯

Input Text placeholder Attribute

Input Text Object

Example

Modify the placeholder text of a text field:

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

Definition and Usage

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

The placeholder attribute provides a hint of the expected value for the input field.

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


Browser Support

All major browsers support the placeholder attribute.

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


Syntax

Return the placeholder attribute:

Set the placeholder attribute:

Attribute Values

Value Description
text Specifies a short hint (a word or a phrase) that describes the expected value of the text field

| Return Value: | String, a short hint that describes the expected value of the text field | | --- | --- |


More Examples

Example

Get the placeholder text of a text field:

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

x outputs:

Name

Related Pages

HTML Reference: HTML <input> placeholder Attribute

❮ Event Onloadstart Met Node Isequalnode ❯