Open In App

HTML | DOM Textarea placeholder Property

The DOM Textarea placeHolder Property is used to set or return the value of the placeholder attribute of a textarea field. It specifies a short hint that describes the expected value of an input field / textarea. A short message or hint displayed before entering value in textarea.

Syntax:



Property Values:

Return Value: It returns a string value which represents the short hint that describes the expected value of an input field.



Example-1: This example illustrates how to set the textarea placeholder Property.




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="font-size:25px;
                   font-style:italic;">
          GeeksForGeeks
      </h1>
        
        <h2 style="font-size:25px;
                   font-style:italic;">
          DOM Placeholder Textarea Property
      </h2>
      Give your Intro:
        
      <textarea id="GFG" 
                rows="4"
                cols="40"
                placeholder="Write something here"
                " about yourself...">
      </textarea>
      <br>
      <br>
        
      <button onclick="myGeeks()">Submit</button>
  
        <script>
            function myGeeks() {
                
                // Set hint for input field.
                document.getElementById(
                  "GFG").placeholder = 
                  "What is your Name?";
            }
        </script>
    </center>
  
</body>
  
</html>

Output:

Article Tags :