以下代碼在除Internet Explorer 9之外的其他任何瀏覽器中都能很好地工作。 顏色透明CSS不起作用。透明色在Internet Explorer中不起作用
HTML:
<select class="selectElement" runat="server" id="dropdown_">
<option value="N">N</option>
<option value="G">G</option>
<option value="O">O</option>
<option value="A">A</option>
<option value="R">R</option>
<option value="U">U</option>
</select>
CSS:
.selectElement {
height: 50px;
width: 80px;
border: solid 1px #c8c8c8;
color:transparent;
}
的jQuery:
$(document).ready(function() {
$('select[id^=dropdown]').children().each(function() {
colors = { "N": "lightgrey", "G": "green", "O": "orange", "A": "yellow", "R": "red", "U": "purple" }
$(this).attr('style', 'background-color:' + colors[$(this).val()] + ';');
});
$('select[id^=dropdown]').change(function() {
$(this).attr('style', $(this).find('option:selected').attr('style'));
}).change();
$('select[id^=dropdown]')
.mousedown(function() { $(this).css('color', 'black') })
.blur(function() { SetStyle(this) })
.change(function() { SetStyle(this) })
SetStyle('#dropdown'); // So that we style on load
function SetStyle(obj) {
var color = $(obj).find('option:selected').css('background-color');
$(obj).css({
'color': 'rgba(0,0,0,0)',
'background-color': color
});
}
});
您在IE中呈現哪種文檔模式?什麼是您使用的文檔類型? – teewuane 2013-05-13 15:22:43
我正在使用ASP.NET web表單 – Singh 2013-05-13 15:25:51
Jag,看看你的html。在.aspx開頭或其他地方,你會看到<!doctype html>或類似的東西。此外,你可以推F12(從Windows)來拉動IE中的開發工具。您將在那裏看到文檔模式和瀏覽器模式。它是什麼? – teewuane 2013-05-13 15:27:05