I want to change the text color of the option that is selected="selected":
<select class="select">
<option value="--">--</option>
<option value="2014">2014</option>
<option value="2013">2013</option>
<option value="2012" selected="selected">2012</option>
<option value="2011">2011</option>
</select>
I have been trying with CSS but it seems its not possible:
.select select [selected="selected"]{
color: #2b2b2b;
}
Any ideas with jQuery?
I have been trying with CSS but it seems its not possible:
Because you are targetting the select
tag and not option
tag also, that selector means select any select
element nested inside element having .select
class
select option[selected] {
color: red;
}
Demo
You are using class
so you can make a selector like
.select option[selected] {
color: red;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With