JSFiddle - React, Tailwind, and code Playground

HTML

<select id="ddl" style="background:#0f0">
    <option style="background:#0f0">a</option>       
    <option style="background:#f00">b</option>   
    <option>c</option>
</select>

JavaScript

$(document).ready(function() {
  $("#ddl").change(function(evt) {
     var select = evt.currentTarget;
     var item = select.item(select.selectedIndex);
     var style = $(item).attr("style");
     if (style) {
       $("#ddl").css({"background-color": style.substring(11)});
     } else {
       $("#ddl").css({"background-color": ""});
     }
  });
});