Ad
How To Change The Color Of Select Text
how to change the color of the dropdown text that I am given red but initially it look like black when we click that it look like red, so how to change that initially it look like red color
<select>
<option style="color:red">one</option>
<option style="color:red">two</option>
</select>
Ad
Answer
You should apply the style to the select, not to the option.
Setting style="color:red"
will set the color of the option to red.
Setting style="color:green"
will set the color of select to green
<select style="color:green">
<option style="color:red">one</option>
<option style="color:red">two</option>
</select>
If you dont want the color of options to be updated, use color: initial
for the option.
select {
color: red;
}
select option {
color: initial;
}
<select>
<option>one</option>
<option>two</option>
</select>
Ad
source: stackoverflow.com
Related Questions
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → laravel blade templating error
- → should I choose reactjs+f7 or f7+vue.js?
- → How to dynamically add class to parent div of focused input field?
- → Setting the maxlength of text in an element that is displayed
- → Undefined Result for Variable with Javascript innerHTML function
- → Expanding search bar not expanding before search
- → Get the calling element with vue.js
- → Blade: how to include a section in one page but not in another
- → How to print/log reactjs rendered dom?
- → how to write react component to construct HTML DOM
- → How to add a timer in HTML5 and Javascript?
Ad