Chained Selects Step-by-step: Apply CSS to list options

We can apply CSS settings to options in a select list, for example:

<option value="red" class="red">Red</option>
<option value="blue" class="blue">Blue</option>

To do so in CS, we have the following syntax:

addList("list-name", "option-text", "option-value", "sub-list-name", default-option-flag, "option-label", "option-css-class");
addOption("list-name", "option-text", "option-value", default-option-flag, "option-label", "option-css-class");

The default-option-flag and option-label parameters are optional, if we just want to specify the option-css-class, we can use empty strings for those two parameters:

addList("list-name", "option-text", "option-value", "sub-list-name", "", "", "option-css-class");
addOption("list-name", "option-text", "option-value", "", "", "option-css-class");

Click [ here ] to see a demo page.

[ Back to main page ]

# # #