Javascript DOM HTML Textarea disabled Property set

Introduction

Disable a text area:

document.getElementById("myTextarea").disabled = true;

Click the button to disable 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 onclick="myFunction()">Disable Textarea</button>

<script>
function myFunction() {/*from   w w w  .  j a  v a 2  s  .  co m*/
  document.getElementById("myTextarea").disabled = true;
}
</script>

</body>
</html>

The disabled property sets or gets whether a text area should be disabled.

This property mirrors the HTML disabled attribute.

Value Description
trueThe text area is disabled
falseDefault. The text area is not disabled

The disabled property returns true if the text area is disabled, otherwise it returns false




PreviousNext

Related