I have html <select>
element that is populated by data in database using javascript append. I wanted to make distinction by applying style="color:red"
for values that have payment_status = false
and style="color:green"
for values that have payment_status = true
. How would I be able to insert style on it. I tried to insert style but the values won't show up in the dropdownlist. Please help me figure this out. Please take a look at the code below. Thank you.
$('#schedule_payment').append($('<option>', {
value: '',
text: 'Select Schedule'
}));
$.each(obj.amortizations, function(i, item) {
if (item.payment_status == true) {
$('#schedule_payment').append($('<option style="color:red">', {
value: item.schedule,
text: item.schedule
}));
} else {
$('#schedule_payment').append($('<option>', {
value: item.schedule,
text: item.schedule
}));
}
});