Javascript examples for DOM HTML Element:Textarea
The defaultValue property sets or gets the default value of a text area, which is the value between the <textarea> and </textarea> tags.
Set the defaultValue property with the following Values
Value | Description |
---|---|
text | Sets the default value (contents) of the text area |
A String, representing the default value of the text area
The following code shows how to change the default value of a text area:
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea"> Main Street// w w w .j ava 2 s .c om New York</textarea> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() { document.getElementById("myTextarea").defaultValue = "new value"; } </script> </body> </html>