Disable a text area:
document.getElementById("myTextarea").disabled = true;
Click the button to disable the text area.
<!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 |
---|---|
true | The text area is disabled |
false | Default. The text area is not disabled |
The disabled property returns true if the text area is disabled, otherwise it returns false