I tried below code to change color of a few disabled select items. However it didn't work. So I tried to change the color of the select field by reading its attribute, but that is not working.
Any help would be great. Is there any way I can do this in css?. I'm very new to this. Please correct any errors. Thank you
<select disabled style="color:red">
<option>
--Select--
</option>
<option class="red">
one
</option>
<option>
two
</option>
<option class="red">
three
</option>
<option>
four
</option>
</select>
Script
jQuery(document).on("change", function(event) {
if ($(this).find("style="color: red;")("red ")){
$(this).addClass("redtext");
}else {
$(this).removeClass("redtext");
}
});
.red{color:red !important;}
.redtext{color:#f00 !important;}
.redtext, .select_red:disabled{color:#f00 !important;}