Problem
A disabled select does not highlight the selected options.
1: <select size="3" multiple="multiple" id="mySelect" disabled="disabled">
2: <option selected="selected" value="Option1">Option 1</option>
3: <option selected="selected" value="Option2">Option 2</option>
4: <option value="Option3">Option 3</option>
5: </select>
Solution
The following CSS provides a workaround. It looks pretty similar to the appearance we are used to.
1: select[disabled="disabled"][multiple="multiple"]{ 2: background-color:#D4D0C8; 3: } 4: 5: select[disabled="disabled"][multiple="multiple"] option[selected="selected"]{ 6: background-color:navy; 7: } Still not working?
Make sure you are using a transitional doctype.
1: <!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->
1: <meta http-equiv="X-UA-Compatible" content="IE=8">
I tested this on IE8, FireFox and Opera.
Better fix?
Please let me know!
Great. Thank you so much.
ReplyDeleteGlad you found it useful!
ReplyDeletejeff you are THE MAN
ReplyDeletethis does not work in ie7.
ReplyDeleteWith jQuery:
ReplyDelete$('#mySelect option[selected]').css('background-color', '#5CACEE');
Thanks for your contribution.
ReplyDeleteWhat about changing the font color to white? Is it posible???
ReplyDeleteHave you tried adding 'color: #FFFFFF'?
ReplyDeletePerfect solution. Thanks!!
ReplyDelete