簡體   English   中英

我可以在IE中更改Disabled HTML Select Element的顏色嗎?

[英]Can I change the color of Disabled HTML Select Element in IE?

我需要更改html選擇的顏色。 我搜索了很多,但沒有找到適用於IE的樣本。 那么,我可以在IE中更改Disabled HTML Select Element的顏色嗎? 我需要一個示例,在css或javascript或jquery中。 這是我嘗試過的。

<select disabled="disabled">
    <option value="a">option A</option>
    <option value="b">option B</option>
    <option value="c">option C</option>
</select>

[disabled] {
  color: #933;
  background-color: #ffc;
}


select:disabled
{
    border: solid 1px silver;
    background-color: #F9F9F9;
    color:blue;
}


[disabled] option {
    background-color: #ffc;  color: #933;
}

解決方案是使用::-ms-value選擇器:

select[disabled]::-ms-value {
    color: red;
}

嘗試

[disabled="disabled"] {
    color: #933;
    background-color: #ffc;
}

要么

*[disabled="disabled"] {
    color: #933;
    background-color: #ffc;
}

要么

select[disabled="disabled"] {
    color: #933;
    background-color: #ffc;
}

或者使用jQuery

<script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('[disabled="disabled"]').css({ 'color': '#993333', 'background-color': '#ffffcc' });
    });
</script>

事實上,上述/下面的答案都不適用於我,但這樣做:

# Select all disabled DOM objects
$(':disabled').css({
    color:'red'
});

# Select disabled DOM objects by HTML tag <input>
$('input:disabled').css({
    color:'red'
});

有關更多信息: https//api.jquery.com/disabled-selector/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM