bodokaiser
bodokaiser

Reputation: 15752

CSS: Style the selected of select list

I have a select list:

<select multiple="multiple">
<option value="1">Macrostructures</option>
<option value="2">Woven</option>
<option value="3">Mystic Bird</option>
</select>

Now when somepody selects an option the option has a blue background. I know want to change the background color.

I already tried:

select option:checked { background: #787878; }

But this doesn't work. How is the correct selector?

Regards

Upvotes: 0

Views: 1056

Answers (1)

Asaithambi Perumal
Asaithambi Perumal

Reputation: 81

check this

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

Upvotes: 1

Related Questions