Why does IE (IE8, specifically) not highlight selected option in a multi select box which is disabled?

淺唱寂寞╮ 提交于 2019-12-13 06:32:13

问题


I am having a multi select box in a JSP page which has some options and is disabled.

<select id="mySelectBox" multiple disabled>
    <option value="first" selected>First</option>
    <option value="second">Second</option>
    <option value="third">Third</option>
    <option value="fourth" selected>Fourth</option>
</select>

I have the first and the fourth options selected, but they are not highlighted in IE They are properly highlighted when I use Firefox.

Is there any solution or workaround for this?

EDIT: My DOCTYPE is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> But even with that I don't see any difference.


回答1:


I hope i clearly understand what you want to do, but i can sugest to do it with little jquery?

<script type="text/javascript"> 
   $(document).ready(function() {
         $("#mySelectBox option:selected").css('background','black');
   });
</script>



回答2:


Interestingly, this CSS workaround seems to have fixed my issue!!

select[disabled="disabled"][multiple="multiple"]{
    background-color:#D4D0C8;
} 
select[disabled="disabled"][multiple="multiple"] option[selected="selected"]{
    background-color:navy;
}

Interesting because, earlier I had used the same to no effect. Perhaps I had missed out on something then.



来源:https://stackoverflow.com/questions/24881640/why-does-ie-ie8-specifically-not-highlight-selected-option-in-a-multi-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!