You can access a Textarea object by indexing the elements array of the corresponding form, or by using the getElementById() method.
Example
Get the text content of a textarea:
var
x
=
document
.
getElementById
(
"
myTextarea
"
)
.
value
;
Try it »
Tip: You can also find it through the form collection's
Create a Textarea object
We can use the document.createElement() method to create
Example
Create a textarea element:
var
x
=
document
.
createElement
(
"
TEXTAREA
"
)
;
Try it »
Textarea Object Attributes.
Attribute
Description
W3C
autofocusSets or returns whether the textarea automatically gets focus. Yes colsSets or returns the width of the textarea. Yes defaultValueSets or returns the initial content of the text box. Yes disabledSets or returns whether the textarea should be disabled. Yes formReturns a reference to the form object that contains the textarea. Yes maxLengthSets the maximum number of characters that can be entered in the textarea element. Yes nameSets or returns the name of the textarea. Yes placeholderSets or returns the value of the placeholder attribute. Yes readOnlySets or returns whether the textarea should be read-only. Yes requireSets or returns whether the textarea is required. Yes rowsSets or returns the height of the textarea. Yes typeReturns the form type of the text box. Yes valueSets or returns the text in the textarea. Yes