【发布时间】:2011-06-29 21:46:08
【问题描述】:
我需要设置 disabled <select>elements 的样式,使它们看起来像是已启用。有人可以帮忙吗?
PS。我非常清楚做这种事情相对于 HCI 原则等的缺点,但这是一项要求,所以如果可能的话,我必须这样做......
谢谢。
编辑:
@AlexThomas 的方法在 HTML 代码中禁用元素时效果很好,但不幸的是我正在使用 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']") //doesn't return anything.
和
`$(".dayselector [disabled='false']") //doesn't return anything.
我有什么遗漏吗?
【问题讨论】:
标签: html css forms css-selectors