HTML DOM Textarea disabled Property



The HTML DOM Textarea disabled property returns and modify whether the text area element in an HTML document is disabled or not.

Syntax

Following is the syntax −

1. Returning disabled

object.disabled

2. Adding disabled

object.disabled = true | false

Let us see an example of HTML DOM Textarea disabled Property:

Example

Live Demo

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      background: lightseagreen;
      height: 100vh;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
   }
</style>
<body>
<h1>DOM Textarea disabled Property Demo</h1>
<textarea placeholder="Hi! I'm placeholder text of a textarea element" rows="8" cols='20'></textarea>
<button onclick="set()" class="btn">Disable Textarea</button>
<script>
   function set() {
      document.querySelector("textarea").disabled = true;
   }
</script>
</body>
</html>

Output

Click on “Disable Textarea” button to disabled the textarea element.


Advertisements