是否可以用CSS样式禁用INPUT元素? [英] Is it Possible to Style a Disabled INPUT element with CSS?
本文介绍了是否可以用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屋!
查看全文