Update 01
Give this a try, it is effectively the same, but see if chrome on mac is happy with this :-)
function selectionChanged(){
var selectElement = document.getElementById('test');
var selectedOption = selectElement.selectedIndex;
selectElement.style.color = selectElement.options[selectedOption].value;
}
<select name="test" id="test" onchange="selectionChanged()" style="color: green">
<option value="green" style="color:green;">this is green</option>
<option value="red" style="color:red;">this is red</option>
</select>
Original answer:
Perhaps what you need is....
<select name="test" id="test" onchange="document.getElementById('test').style.color = document.getElementById('test').options[document.getElementById('test').selectedIndex].value" style="color: green">
<option value="green" style="color:green;">this is green</option>
<option value="red" style="color:red;">this is red</option>
</select>
- Note that the green color is hard-coded for
select element since the first / default option is green
- and then
onchange of select will re-apply the style based on selected option. (You could also create a specific function in JS, but this code will do the trick if your requirements are not going to grow)