views:

335

answers:

1

I have a select tag that looks like this:

<select style="background:#fa7171; color:#FFFFFF;" name="product_type_sub" id="product_type_sub" onChange="ajaxFunction(1);">
    <option value="None Selected">None Selected</option>
</select>

You can see the inline css sayin the font should be white, and it is at first. but I add/remove more options with Javascript and Ajax.

Here is how I add options:

next.options[i+1]=new Option(newFields[i], newFields[i], false, false);

But any options that I add are not in a white font, they ignore the CSS, is there a way to enforce this?

Thanks!!

+2  A: 

Set color on an option element directly. For example:

var optionEl = new Option(newFields[i], newFields[i], false, false); 
optionEl.style.color = 'red'; 
next.options[i+1] = optionEl;
kangax