Javascript DOM HTML Textarea Object get

Introduction

The Textarea object represents an HTML <textarea> element.

We can access a <textarea> element via document.getElementById():

var x = document.getElementById("myTextarea");

Click the button to get the content of the text area.

View in separate window

<!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>

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

<script>
function myFunction() {//ww  w  .j a v  a  2 s.co  m
  var x = document.getElementById("myTextarea").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related