Get Textarea Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea


The Textarea object represents an HTML <textarea> element.

You can access a <textarea> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<textarea id="myTextarea">
text text text//from   w  ww.ja v  a  2 s  .  c om

<button type="button" onclick="myFunction()">get the content of the text area</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myTextarea").value;
    document.getElementById("demo").innerHTML = x;


Related Tutorials