-1

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

TylerH
  • 20,799
  • 66
  • 75
  • 101
htunc
  • 455
  • 5
  • 19
  • 1
    Duplicate of [How to apply background-color to a selected option?](https://stackoverflow.com/questions/18091866/how-to-apply-background-color-to-a-selected-option) – TylerH Sep 08 '20 at 19:52

1 Answers1

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);
Community
  • 1
  • 1
Black Bird
  • 797
  • 1
  • 10
  • 34
  • there is not way for me to change the color of a selected option in a multiselect, neither its background color ( at least on chrome ) – WonderLand Sep 24 '14 at 16:45