Jquery 使禁用的输入保持与启用的颜色相同

Jquery 使禁用的输入保持与启用的颜色相同,jquery,html,css,Jquery,Html,Css,我有一个带有类的输入字段: .list-default .value { font-size: 14px; font-weight: bold; color: #333333; float: left; width: 55%; background-color: transparent; text-align: right; overflow: hidden; text-overflow: ellipsis; pa

我有一个带有类的输入字段:

.list-default .value 
{
    font-size: 14px;
    font-weight: bold;
    color: #333333;
    float: left;
    width: 55%;
    background-color: transparent;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 12px 0px 10px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}
.list-default .value:disabled
{
    opacity:1;
    font-size: 14px;
    font-weight: bold;
    color: #000000 !important;
    float: left;
    width: 55%;
    background-color: transparent;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 12px 0px 10px;
    -moz-box-shadow: none;
    -webkit-box-shadow: none;
    box-shadow: none;
}
当我使用jquery或html将disabled设置为
true
时,颜色变为浅灰色,但如果我将颜色设置为例如红色,则颜色为亮红色


即使已禁用,如何使输入文本颜色相同?

它是
input[disabled]
而不是
input:disabled

在yout的情况下:

.list-default .value[disabled]

我认为您应该将其设置为只读而不是禁用

您也可以在其上应用样式

HTML:

<form name="fish">
    <input type="text" name="big" value="Big Fish">
    <input type="text" name="little" value="Little Fish">
    <input type="text" name="tiny" value="Tiny Fish" readonly>
</form>
document.forms['fish']['big'].readOnly = true;
input[readonly] {
    color: #999;
}
CSS:

<form name="fish">
    <input type="text" name="big" value="Big Fish">
    <input type="text" name="little" value="Little Fish">
    <input type="text" name="tiny" value="Tiny Fish" readonly>
</form>
document.forms['fish']['big'].readOnly = true;
input[readonly] {
    color: #999;
}
查看下面的小提琴:


尝试在选择器中使用
[disabled]
而不是
:disabled
在我的iphone上不起作用我可能会添加到iphone上!不,它仍然不起作用。当类被禁用但颜色改变时,会添加该类。它似乎这样做,以黑色和灰色的颜色,但如果你把红色或绿色的一切都是好的。