Change the contents of a text area:
document.getElementById("myTextarea").value = "Main Street";
Click the button to change the contents of the text area.
<!DOCTYPE html> <html> <body> Address:<br> <textarea id="myTextarea"> PO 1234, Main Street U.S.A. New York</textarea> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() {//from w w w . ja va2 s .c o m document.getElementById("myTextarea").value = "Main Street"; } </script> </body> </html>
The value
property sets or gets the contents of a text area.
The value of a text area is the text between the <textarea> and </textarea> tags.
The value property accepts and returns a String type value.