In order to disable a textarea (or any other input element), you can:
In HTML, you can write: <textarea id='mytextarea' disabled></textarea>
From jQuery, you can: $("#mytextarea").attr("disabled","disabled");
CSS? Is it possible to disable the textarea with CSS?
When present, it specifies that the text area should be disabled. A disabled text area is unusable and the text is not selectable (cannot be copied). The disabled attribute can be set to keep a user from using the text area until some other condition has been met (like selecting a checkbox, etc.).
Easiest solution, add an id, and use getElementById. Almost. Remove the quotes around "false" to make the argument a boolean and not a string, and you'll have it.
The :disabled CSS pseudo-class represents any disabled element. An element is disabled if it can't be activated (selected, clicked on, typed into, etc.) or accept focus. The element also has an enabled state, in which it can be activated or accept focus.
To disable the resizing (drag thumb) just use resize: none; . To restrict size max(min)-width and height should do the trick.
You can make a textarea appear disabled, but you can't actually disable it.
Using JavaScript, all you're really doing is modifying the same DOM attribute that's set by the HTML disabled
attribute, so using HTML and JavaScript you're essentially doing the same thing. CSS, however, is completely out of this picture, as it doesn't do DOM manipulation of any sort — all it controls is the appearance (visual or otherwise) of an element, not its behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With