Possible Duplicate:
HTML <select>开发者_开发百科 selected option background-color CSS style
How can I change the color of the selected option in dropdown list? I need to change the color of the option which is visible when the dropdown is closed...
You can get the value from select.options[select.selectedIndex], so this might fit your needs: http://jsfiddle.net/6VhK8/.
var select = document.getElementById('select');
select.onchange = function() {
    for(var i = 0; i < select.options.length; i++) {
        if(i == select.selectedIndex) {
            select.options[i]
            .style.backgroundColor = 'red';
        } else {
            select.options[i]
            .style.backgroundColor = '';
        }
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论