try this: $("#custom1 option").each(function(){ var class = $(this).html(); addClass(class); });
Eduardo Pinzon Web Developer 2009/8/10 Benn <bennmey...@gmail.com> > > This might have been resolved, but I can't find a solution with my > search. I'm trying to add a class with the text of the option. Simple > to do the selected option, but not all of them it seems. > > I want to change: > > <select class="required" id="custom1" name="custom1"> > <option selected="" value=""/> > <option value="1">Text 1</option> > <option value="2">Text 2</option> > <option value="3">Text 3</option> > </select> > > to: > > <select class="required" id="custom1" name="custom1"> > <option selected="" value=""/> > <option value="1" class="Text 1">Text 1</option> > <option value="2" class="Text 2">Text 2</option> > <option value="3" class="Text 3">Text 3</option> > </select> > > I have tried $('#selectList :selected').text() and $.map($ > ('#foo :selected'), function(e) { return $(e).text(); }) but to no > avail... I feel like I'm missing something