问题
I'm having this problem where I need to change the color of a/multiple option element(s) when clicked/ selected. Default color is blue when clicked, I believe we should have a solution for this now since I've try to search for solutions but to no avail. Hoping to do this in CSS or vanilla JS. no libraries or frameworks.
Link to sample code
回答1:
select[multiple]:focus option:checked {
background: red linear-gradient(0deg, red 0%, red 100%);
}
<select multiple>
<option value="1">one</option>
<option value="2" selected>two</option>
<option value="3">three</option>
</select>
来源:https://stackoverflow.com/questions/50618602/change-color-of-selected-option-in-select-multiple