Javascript DOM HTML Textarea readOnly Property get

Introduction

Find out if a text area is read-only or not:

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

Click the button to find out whether the text area is read-only, or not.

View in separate window

<!DOCTYPE html>
<html>
<body>

Address:<br>
<textarea id="myTextarea" readonly>
PO 1234, Main Street U.S.A.
New York</textarea>
<button type="button" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {// w w w  . ja  va 2  s  .co  m
  var x = document.getElementById("myTextarea").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related