JSFiddle - React, Tailwind, and code Playground

by thecodeparadox

HTML

<select name="select1" id ="select1" onchange="handleSelect()">
<option value ="-1">ALL</option>
<optgroup label="CARS">
<option value="ford">FORD</option>
<option value="Nissan">Nissan</option>
</optgroup>
</select>

JavaScript

function handleSelect(){
    var selectVal = $("#select1:selected").text();
         if (selectVal == "ALL"){
                // cannot disable all the options in select box
             $("#select1  option").attr("disabled","disabled");  

         }else{                      
             $("#select1 option[value='-1']").attr('disabled','disabled');
             $("#select1 option").attr('disabled','');
        }
}