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:

  • It is used to Return the placeholder property.
    textareaObject.placeholder
  • It is used to Set the placeholder property.
    textareaObject.placeholder = text

Property Values:



  • text: It display a message / short-hint that describes the expected value of a input.

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output: