Open In App

HTML | DOM Textarea Object

The Textarea Object in HTML DOM is used to represent the HTML <textarea> Element. The textarea element can be accessed by using getElementById() method.
Syntax: 
 

document.getElementById("ID"); 

Where ID is assigned to the <textarea> element.
Property Values: 
 



Methods: 
 

Example 1: This example describes the getElementById() method to access the <textare> element. 
 






<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Textarea Object
        </title>
    </head>
     
    <body style = "text-align:center">
              
        <h1 style = "color: green;">
            GeeksforGeeks
        </h1>
         
        <h2>DOM Textarea Object</h2>
 
        <!--A disabled textarea-->
        <textarea id = "myGeeks">
            GeeksForGeeks.A computer science portal for Geeks.
        </textarea>
         
        <br>
         
        <button onclick = "Geeks()">
            Submit
        </button>
         
        <p id = "sudo"></p>
 
 
 
        <script>
            function Geeks() {
                var x = document.getElementById("myGeeks").value;
                document.getElementById("sudo").innerHTML = x;
            }
        </script>
    </body>
</html>                   

Output: 
Before Click on the Button: 
 

After Click on the Button: 
 

Example 2: Textarea Object can be created by using the document.createElement method. 
 




<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM Textarea Object
        </title>
    </head>
     
    <body style = "text-align:center">    
     
        <h1 style = "color: green;">
            GeeksforGeeks
        </h1>
         
        <h2>DOM Textarea Object</h2>
         
        <button onclick = "Geeks()">
            Submit
        </button>
         
        <!-- script to create textarea -->
        <script>
            function Geeks() {
                 
                // textarea tag is created
                var g = document.createElement("TEXTAREA");
                 
                var f = document.createTextNode(
                "GeeksForGeeks.A computer science portal for Geeks.");
                 
                g.appendChild(f);
                document.body.appendChild(g);
            }
        </script>
    </body>
</html>                   

Output: 
Before Click on the Button: 
 

After Click on the Button: 
 

Supported Browsers: The browser supported by DOM Textarea Object are listed below: 
 

 


Article Tags :