I am trying to change the font color of specific option elements within a select dropdown by adding style="color: #D4D4D4"
. When I apply this style directly to an option element like
<option value="TEST" style="color: #D4D4D4">TEST</option>
, it works when the options are expanded. However, the selected option (when the dropdown is closed) still shows the default font color. How can I change this as well?
Update:
Thank you for the suggestion! Unfortunately, using sel.onchange
does not track attribute changes made to option elements. I am using jQuery to set attributes and need the updates to be immediately reflected in the select dropdown. Is there a way to achieve this?
Here is my jQuery code:
$('.form-control option[value="' + $scope.environment + '"]').attr('style', 'color: #D4D4D4');