Javascript DOM HTML Textarea defaultValue Property get

Introduction

Get the default value of a text area:

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

Click the button to display the default value 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 2s . co  m
  var x = document.getElementById("myTextarea").defaultValue;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related