Textarea value Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea


The value property sets or gets the contents of a text area, which is the text between the <textarea> and </textarea> tags.

Set the value property with the following Values

Value Description
text Sets the value (contents) of the text area

Return Value

A String, representing the contents/text of the text area

The following code shows how to change the contents of a text area:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<textarea id="myTextarea">
Main Street//from   w  w w  . j av  a  2 s . c o m
New York</textarea>

<button type="button" onclick="myFunction()">Test</button>

function myFunction() {
    document.getElementById("myTextarea").value = "new value";


Related Tutorials