Follow-up to this question: Setting background-color of select options in JQuery
I have a page with multiple select boxes, as per the following:
<
$("select[id$=-status][id^=id_item-]").change(function (){
var style = $(this).find('option:selected').attr('style');
$(this).attr('style', style);
$("select[id$=-status][id^=id_item-] option:selected").each(function () {
$(this).attr('style', style);
});
}).trigger('change');
Add style to you HTML code, use trigger don't forget to load this in your $(document).ready(function(){}
Also don't forget to put this code after populating your Select box from the DB