I am currently struggling with adding a drop-down list to my form that displays 2 values, with the second value having a different text color (light gray). After some research, it seems like I need to use JavaScript for this customization. However, as I am not proficient in JavaScript, my attempts so far have been unsuccessful.
<select name="cities">
<option value="1">New York (USA)</option>
<option value="2">Tokyo (Japan)</option>
<option value="3">Paris (France)</option>
</select>
Some approaches I've tried include:
<option value="1">
<span style="text-decoration:line-through">New York</span>
<span style="color:lightgray;font-weight:bold">(USA)</span>
</option>
and
<script type="text/javascript">
document.getElementById('country').style.color = 'lightgray';
</script>
<option value="1">New York <span id='country' style='color:lightgray'>(USA)</span></option>
Although these methods worked on platforms like fiddle, they are not functioning properly on my website.
A similar option can be found on this thread about assigning color to select OPTION.
If anyone has a straightforward piece of JavaScript code to achieve this effect, I would greatly appreciate your help.