Input Text defaultValueProperty

Input Text 对象参考手册Input Text Object

Example

Modify the default value of the text field:

document.getElementById("myText").defaultValue = "Goofy";

Try it Yourself »


Definition and Usage

The defaultValue property sets or returns the default value of a text field.

Note:This default value is the value specified in the HTML "value" attribute.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the defaultValue property.


Syntax

Return the defaultValue property:

textObject.defaultValue

Set the defaultValue property:

textObject.defaultValue=value

Property Values

Value Description
value Describes the default value of the text field

Technical Details

Return Value: A string representing the default value of the text field


More Examples

Example

Get the default value of the text field:

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

xThe output result is:

Mickey

Try it Yourself »


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