如何制作灰色的HTML表单? [英] How to make a greyed-out HTML form?

查看:234
本文介绍了如何制作灰色的HTML表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有一组HTML文本< input> ,它们可以同时变为灰色(禁用)。我也希望他们所在的整个区域以某种方式呈灰色或至少明显被禁用。我已经在桌面应用程序中看到过类似的东西。



任何想法都可以通过简单/优雅的方式来实现?我试图避免手动将 disabled =disabled设置为 区域 ;输入> 表示整个表单部分不可编辑。

编辑:对不起,我应该再提一点事情......


  1. 一切都是本地的。我没有使用
    PHP或ASP或类似的东西...
    只是HTML,JavaScript和CSS。也没有jquery!

  2. 我想用JavaScript动态地启用/禁用区域

  3. 它不是<表格> ,只是一堆< input>


解决方案

disabled =disabled参数是执行此操作的标准方法,您可以使用类似jQuery的动态方式来禁用字段集中包含的所有表单元素(这是分组相关表单元素的标准方式)。



或者,您可以在字段集上放置一个部分透明的div。这也将阻止鼠标单击的表单元素,但不会防止对它们进行标记。你应该仍然自己禁用表单元素。


I'd like to have a group of HTML text <input>'s that can be all greyed-out (disabled) at the same time. I also want the entire area they are in to somehow be greyed-out or at least visibly disabled. I've seen things like this done in desktop applications.

Any ideas on an easy/elegant way to do it? I'm trying to avoid manually setting each to disabled="disabled", and also have an area surrounding the <input>'s that indicates that entire portion of the form is non-editable.

EDIT: Sorry, I should mention a few more things...

  1. Everything is local. I'm not using PHP or ASP or anything like that... just HTML, JavaScript, and CSS. Also no jquery!
  2. I want to enable/disable the "area" dynamically with JavaScript
  3. It's NOT a <form>, just a bunch of <input>'s

解决方案

The disabled="disabled" parameter is the standard way to do this, and you could use something like jQuery to dynamically disable all of the form elements contained in a fieldset (Which is the standard way of grouping related form elements) on the fly.

Alternatively you could place a partially transparent div on top of the fieldset. This will also provide some blocking of the form elements from mouse clicks, but will not protect against tabbing to them. You should still disable the form elements themselves.

这篇关于如何制作灰色的HTML表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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