是否可以用CSS样式禁用INPUT元素? [英] Is it Possible to Style a Disabled INPUT element with CSS?

查看:82
本文介绍了是否可以用CSS样式禁用INPUT元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要样式 disabled < select> 喜欢他们启用。有人可以帮忙吗?

I need to style disabled <select>elements to make them look like they're enabled. Can someone help?

PS。我完全意识到这样的事情与HCI原则等的缺点,但它的要求,所以我必须这样做,如果它是可能...

PS. I am all-too-aware of the downsides of doing this sort of thing vis a vis HCI principles etc., but its a requirement so I've got to do it if it is possible ...

感谢。

编辑:

@AlexThomas'元素在HTML代码中禁用,但不幸的是我正在使用JQuery禁用/启用:

@AlexThomas' method works well when the elements are disabled in HTML code but unfortunately I'm doing the disabling/enabling with JQuery:

<select class='dayselector'>
    <option>Monday</option>
    <option>Tuesday</option>
    <!-- .... etc. -->
</select>

$(".dayselector").attr("disabled",true);

$(".dayselector").attr("disabled",false);

所以选择器:

$(".dayselector")  //works and gets all the selects

$(".dayselector option")  //works and gets all the selects' option items



$(。dayselector [disabled ='true'] )//不返回任何内容。

`$(".dayselector [disabled='false']")  //doesn't return anything.

是否有我遗漏的东西?

推荐答案

使用jquery:

$('option[disabled="true"]').each(function () {
                 $(this).attr('style', 'color:red');
});

在此处检查它 http://jsfiddle.net/GfNve

这篇关于是否可以用CSS样式禁用INPUT元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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