问题描述
为了禁用textarea(或任何其他输入元素),您可以:
-
写入:
< textarea id ='mytextarea'disabled>< / textarea>
- p>从jQuery,您可以:
$(#mytextarea)。attr(disabled,disabled);
li>
-
CSS?可以用CSS禁用textarea吗?
您可以让textarea显示为禁用,
使用JavaScript,所有你真正做的是修改由HTML 禁用$ c>设置的相同DOM属性$ c>属性,所以使用HTML和JavaScript你实际上做同样的事情。 CSS,但是,完全没有这张图片,因为它不做任何类型的DOM操作 - 它控制的是一个元素的外观(视觉或其他),而不是它的行为。
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?
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.
这篇关于从CSS禁用Textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!