Change the placeholder text of a text area:
document.getElementById("myTextarea").placeholder = "Where do you live?";
Click the button to change the placeholder text of the text area.
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea" placeholder="Your address.."> </textarea> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w .j av a2s. c o m*/ document.getElementById("myTextarea").placeholder = "Where do you live?"; } </script> </body> </html>
The placeholder property sets or gets the value of the placeholder attribute of a text area.
The placeholder attribute sets a short message for the expected value of a text area.
The hint is displayed in the text area when it is empty.
The placeholder property accepts and returns a String type value.