html - 如何更改 IE 中几个禁用的选择字段的颜色
问题描述
我尝试了下面的代码来更改一些禁用的选择项的颜色,尽管它在 Chrome 中工作但在 IE 中没有。我尝试提供 ::ms-value,但它适用于所有不需要红色的禁用选择字段。有什么办法可以在 Jquery 中做到吗?css 也很好。谢谢
HTML
<select class="select_red" disabled="">
<option>--Select--</option>
<option class="red">one</option>
<option>two</option>
<option class="red">three</option>
<option>four</option>
</select>
脚本
jQuery(document).on("change", ".select_red", function(event){
if($(this).find("option:selected").hasClass("red")){
$(this).addClass("redtext");
}else {
$(this).removeClass("redtext");
}
CSS
.redtext{color:#f00 !important;}
.redtext, .select_red:disabled{color:#f00 !important;}
解决方案
我不确定你能不能。每个浏览器都有自己的方式来设置这些样式。但是,您可以自己制作!
推荐阅读
- linux - 杀死孩子时循环shell脚本被杀死
- javascript - 将时区附加到作为日期对象的时间
- php - 我如何在 CWP(Centos-Web-Panel)中使用 laravel 网站。网址中没有公用文件夹?
- python - 如何在硒python中的jquery日期时间选择器中选择日期
- java - 根据最后一个单词的升序对字符串进行排序
- javascript - 为什么在通过 $.getjson() 传递 var 时无法使用点 (.) 运算符访问 json 属性
- anaconda - Jupyter Notebook 未与内核连接
- javascript - 从同一个方法调用所有同类型的http请求
- c# - MVC 中带有 @Html.DropDownListFor 字段的可编辑 HTML 表
- java - 将 null 强制转换为类型