HTML DOM Textarea Object
Textarea object
The Textarea object represents the HTML <textarea> element.
Access Textarea Object
You can access the <textarea> element using getElementById():
var x = document.getElementById("myTextarea");
Tip:You can also access the <textarea> element by searching the form's elements collection.
Create Textarea Object
You can create a <textarea> element using the document.createElement() method:
var x = document.createElement("TEXTAREA");
Textarea object properties
Attributes | Description |
---|---|
autofocus | Set or return whether the text area should automatically focus when the page is loaded. |
cols | Set or return the cols attribute value of the text area. |
defaultValue | Set or return the default value of the text area. |
disabled | Set or return whether the text area is disabled. |
form | Return a reference to the form containing the text area. |
maxLength | Set or return the maxlength attribute value of the text area. |
name | Set or return the name attribute value of the text area. |
placeholder | Set or return the placeholder attribute value of the text area. |
readOnly | Set or return whether the content of the text area is read-only. |
required | Set or return whether the text area must be filled out before submitting the form. |
rows | Set or return the rows attribute value of the text area. |
type | Return the type of the form element containing the text area. |
value | Set or return the content of the text area. |
wrap | Set or return the wrap attribute value of the text area. |
Textarea object methods
Method | Description |
---|---|
select() | Select the entire content of the text area. |
Standard properties and events
The Textarea object supports both standardAttributesandEvents.