user1460692 user1460692 - 4 months ago 13
CSS Question

how to change background color of selected items in multiselect dropdown box?

I want to give the yellow color to the selected items in multiselect dropdown box. By default it has gray background after selecting,
I want to do this in

HTML, CSS
.

Can any one help in this?

Answer

We can use JS to select the DOMs.

$('select').change(function() {
    $('option').css('background', 'none');
    $('option:selected').css('backgroundColor', 'red');
}).change()

<select>
    <option>1111111</option>
    <option>222222222</option>
    <option>33333333</option>
    <option>44444444</option>
</select>

Demo : http://jsfiddle.net/TxbVt/1/