I would like to change the color of selected item's background. I mean that blue color : http://img844.imageshack.us/img844/3200/c0b8e4b9ceac4122bc5668a.png
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Referencing this post,
Currently CSS does not support this feature. You can build your own or use a plug-in that emulates this behaviour using DIVs/CSS.
However you can achieve it doing Javascript which you can see here
var sel = document.getElementById('select_id');
sel.addEventListener('click', function(el){
var options = this.children;
for(var i=0; i < this.childElementCount; i++){
options[i].style.color = 'white';
}
var selected = this.children[this.selectedIndex];
selected.style.color = 'red';
}, false);
标签:
drop-down-menu