Get Textarea Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Introduction

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>
<html>
<body>

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

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

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

<script>
function myFunction() {
    var x = document.getElementById("myTextarea").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials