I have a page containing many <select> elements. What I'm trying to achieve is to make sure that if the <select> of the selected <option> has a class called italics, then <select> then the italic class is added (i.e. jQuery.addClass('italic')). If this is not the case, then the italic class is removed from the <select> to ensure the other <option> elements are displayed correctly (i.e. jQuery.removeClass('italic')).
What I notice in most of my attempts is that either all <select> have an italic class, or that the italic class is not deleted accordingly.
Since I'm not sure that my choice in selectors and callback logic is particularly good or good in this case (since I frustratedly tried to get it to work), I decided not to include the code that I used in the previous attempt. Instead, refer to this small example of HTML and CSS:
.italic {
font-style: italic;
}
<select id = "foo" name = "foo" size = "1">
<option value = "NA" selected = "selected"> - Select - </option>
<option value = "1"> Bar </option>
<option value = "2"> Fu </option>
<option value = "3"> Baz </option>
</select>
, , CSS- <select> <option> . - J2EE Firefox .