从CSS禁用Textarea [英] Disabling Textarea from CSS

查看:145
本文介绍了从CSS禁用Textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了禁用textarea(或任何其他输入元素),您可以:




  • 写入:
    < textarea id ='mytextarea'disabled>< / textarea>


  • p>从jQuery,您可以:
    $(#mytextarea)。attr(disabled,disabled);

    li>
  • CSS?可以用CSS禁用textarea吗?



解决方案

您可以让textarea显示为禁用,



使用JavaScript,所有你真正做的是修改由HTML 禁用设置的相同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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆