Textarea defaultValue property
Example
Modify the default value of the textarea element:
document
.
getElementById
(
"
myTextarea
"
)
.
defaultValue
=
"
Runoob
"
;
Try it »
Definition and Usage
The defaultValue property sets or returns the initial content of the text box.
**Note:** The initial value of the text box is located in the text between the tags. When the form is reset, the text box will be restored to the entire value. Changing the value of this property will change the text currently displayed in the text box.
Browser support
| property | |||||
|---|---|---|---|---|---|
| defaultValue | Yes | Yes | Yes | Yes | Yes |
Syntax
Set the defaultValue property:
textareaObject.defaultValue = text
Return the defaultValue property:
textareaObject.defaultValue
Tip: The defaultValue property has no default value.
Attribute values
| Value | Description |
|---|---|
| text | Specifies the default value of the text box |
Technical Details
| Return value: | A string, returning the default value of the textarea element. |
|---|
More examples
Example
Get the default value of the textarea element:
var
x
=
document
.
getElementById
(
"
myTextarea
"
)
.
defaultValue
;
Try it »
The Textarea object