That did it Dan. Thanks!

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dan G. Switzer, II
Sent: Wednesday, May 30, 2007 8:56 AM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Forcing a select box to "select" a specified option


Andy,

>Hrm...
>
>That doesn't work. I think you might have misunderstood me though. I 
>want to force the selected attribute of the second option element.
>
>I tried this too:
>$('#RedMakeSelect:first-child option:nth- 
>child(1)').attr('selected','true');
>
>And that didn't work either.

I can't remember if the nth-child() starts at 0 or 1. If it starts at 1,
you'd need to use the value 2.

However, now that you've said you're just trying to select the second item,
I'd do what was previously suggested an go straight to the DOM:

$('#RedMakeSelect:first-child option")[1].selected = true;

-Dan


Reply via email to