Open In App

HTML DOM Textarea type Property

The Textarea type Property in HTML DOM is used to return the type of form element of the Textarea field. Note that, it will always return “textarea” for a Textarea Object.

Syntax:



textareaObject.type

Return Value: It returns a string value that represents the type of form element of the Textarea field.

Example: The below program illustrates the Textarea type property in HTML DOM.






<!DOCTYPE html>
<html>
 
<body style="text-align:center">
    <h1 style="color: green;">
    GeeksforGeeks
    </h1>
    <b>DOM Textarea type Property</b>
    <br><br>
     
    <!-- Assigning id to textarea. -->
    <textarea id="myGeeks" rows="5" autofocus>
GeeksForGeeks. A computer science portal for Geeks.
    </textarea>
    <br><br>
 
    <button onclick="myGeeks()">Submit</button>
    <p id="sudo" style="font-size:20px;color:green;"></p>
 
 
 
    <script>
        function myGeeks() {
           
            // Get the type of textarea
            var type =
              document.getElementById("myGeeks").type;
           
            // Set the type to the innerHTML
            document.getElementById("sudo").innerHTML = type;
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers:


Article Tags :