我可以使用CSS或脚本风格的禁用控件吗? [英] Can I style a disabled control using CSS or script?

查看:71
本文介绍了我可以使用CSS或脚本风格的禁用控件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当页面上的 select 元素更改时,页面上有一个HTML div 元素。有时,基于选择,需要禁用输入标签(文本框)。

I have a HTML div element on a page that is updated when a select element on the page changes. Sometimes the input tags (text boxes) need to be disabled based on the selection.

这里是问题:项目利益相关者喜欢的功能,他们只是认为在禁用状态,文本框内容太轻,因此不可读。我可以将CSS应用于已禁用的控件吗?或者我应该将文本框设置为 readonly 并使用一些其他CSS。这个应用程序也使用jQuery,如果这有帮助。和想法或建议吗?

Here is the problem: the project stakeholders like the functionality, they just think in the "disabled" state, the text box contents are too light and therefore unreadable. Can I apply CSS to a disabled control? Or should I be setting the text boxes to readonly and using some other CSS. This application is also using jQuery, if that helps. And ideas or suggestions here?

推荐答案

input[type="submit"][disabled="disabled"]
{
    /* CSS here */
}
input[type="text"][disabled="disabled"]
{
    /* CSS here */
}
input[type="button"][disabled="disabled"]
{
    /* CSS here */
}

在每个浏览器中都可以使用,如果输入标签类似:

Works in every browser if the input tag is something like:

<input type="submit" disabled="disabled">

如果你想在不禁用的情况下改变它,只需将它添加到CSS



and if you want to change it when it is not disabled, just add this to your CSS

input[type="submit"]
{
    /* CSS here */
}
input[type="text"]
{
    /* CSS here */
}
input[type="button"]
{
    /* CSS here */
}

这篇关于我可以使用CSS或脚本风格的禁用控件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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