[jQuery] Re: set certain items in a select list to selected.

2009-08-03 Thread amuhlou
Maybe the eq() selecor would help more (http://docs.jquery.com/ Selectors/eq) something like: $("#mylist option:eq(2), #mylist option:eq(0), #mylist option:eq (4)").attr("selected", "selected"); On Aug 3, 2:51 pm, shaded wrote: > Not exactly. I guess looping through my string would work. but

[jQuery] Re: set certain items in a select list to selected.

2009-08-03 Thread shaded
Not exactly. I guess looping through my string would work. but its a multiple select list so .addclass wont work i tried using $("#mylist option:contains(3)").attr("selected", "selected"); this compares against the list value, not the id. Is there a way to compare against the id? Better yet,

[jQuery] Re: set certain items in a select list to selected.

2009-08-03 Thread Simon
If I understand correctly what you're asking, would a simple if statement (using OR operators to select 1, 3, or 5) and then using jQuery's .addClass do the trick? http://docs.jquery.com/Attributes/addClass#class complete speculation, but you may also be interested in: http://docs.jquery.com/Sel