 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Textarea Object
The HTML DOM Textarea Object represent the <textarea> element of an HTML document.
Create Textarea object
Syntax
Following is the syntax −
document.createElement(“TEXTAREA”);
Properties of Textarea object
| Property | Explanation | 
|---|---|
| autofocus | It returns and modify whether the text area should automatically get focused or not when the page loads. | 
| defaultValue | It returns and modify the default value of a text area element in an HTML document. | 
| cols | It returns and modify the value of cols attribute of a text area element in an HTML document. | 
| disabled | It returns and modify whether the text area element in an HTML document is disabled or not | 
| form | It returns the cite of the form which enclose the text area. | 
| maxLength | It returns and modify the value of maxLength attribute of a text area element in an HTML document. | 
| name | It returns and modify the value of name attribute of a text area element in an HTML document. | 
| placeholder | It returns and modify the value of placeholder attribute of a text area element in an HTML document. | 
| readOnly | It returns and modify whether the content of a text area element in an HTML document should be read only or not. | 
| required | It returns and modify the value of the required attribute of a text area in an HTML document. | 
| rows | It returns and modify the value of rows attribute of a text area element in an HTML document. | 
| type | It returns the type of the form element the text area is in an HTML document. | 
| value | It returns and modify the content of a text area element in an HTML document. | 
| wrap | It returns and modify the value of wrap attribute of a text area element in an HTML document. | 
Methods of Textarea object
| Method | Explanation | 
|---|---|
| select() | It selects the content of a text area in an HTML document. | 
Let us see an example of Textarea object:
Example
<!DOCTYPE html> <html> <style>    body {       color: #000;       background: lightseagreen;       height: 100vh;       text-align: center;    }    .btn {       background: #db133a;       border: none;       height: 2rem;       border-radius: 2px;       width: 40%;       display: block;       color: #fff;       outline: none;       cursor: pointer;       margin: 1rem auto;    } </style> <body> <h1>DOM Textarea Object Demo</h1> <button onclick="create()" class="btn">Create Textarea</button> <script>    function create() {       var ta = document.createElement("TEXTAREA");       ta.innerHTML = "Hi! I'm a textarea element in an HTML document with some dummy text.";       ta.setAttribute('rows', '8');       document.body.appendChild(ta);    } </script> </body> </html> Output

Click on “Create Textarea” button to create a textarea element.

Advertisements
 