HTML DOM Input Text placeholder attribute
Examples
Modify the prompt text in the text field:
document.getElementById ( "myText") placeholder = "Enter the name in this ...";
try it"
Definition and Usage
placeholder placeholder property sets or returns the property values in the text field.
placeholder attribute tracks the input message fields expected value.
The prompt is displayed in the input field empty, and disappears when the field gets the focus.
Browser Support
All major browsers support the placeholder attribute.
Note: Internet Explorer 9 and earlier versions of IE browser does not support the placeholder attribute.
grammar
Back placeholder attributes:
textObject .placeholder
Setting placeholder properties:
textObject .placeholder = text
Property Value
value | description |
---|---|
text | Provides a brief message (a word or phrase), it is used to describe the expected value of the text field |
return value: | String, a brief reminder text field for describing the expected value |
---|
More examples
Examples
Get the message text field:
var x = document.getElementById ( "myText") placeholder.;
x The output is:
Name
try it"
Related Pages
HTML Reference Manual: HTML <the INPUT> placeholder attribute
Input Text Object