JSFiddle - React, Tailwind, and code Playground

by pj_js15

HTML

<select id="select">
    <option style="color:gray" value="null">select one option</option>
    <option value="1" class="others">one</option>
    <option value="2" class="others">two</option>
</select>

CSS

.others {color:red}

JavaScript

$(document).ready(function() {
    $('#select').css('color','gray');
    $('#select').change(function() {
       var current = $('#select').val();
       if (current != 'null') {
           $('#select').css('color','black');
       } else {
           $('#select').css('color','gray');
       }
    }); 
});