I did. Thanks Josh. I modified it in such a way that given an index x
I can write:
$("#fruits option").get(x).selected = true;
And that did it.
---
On Oct 1, 3:36 pm, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> Did you try my code? It should do what you describe.
>
You could achieve this by using $('#fruits').val('Banana').
All of this is available in the jquery api docs if you take a look. Take a
look at http://docs.jquery.com/Attributes
http://docs.jquery.com/Attributes for examples of what you're trying to
accomplish with the select elements.
GAR
Give this a go:
$("option","#fruits").each(function() {
$(this).attr("selected", $(this).text() == 'Pineapple' );
});
-- Josh
- Original Message -
From: "GARIL" <[EMAIL PROTECTED]>
To: "jQuery (English)"
Sen
Did you try my code? It should do what you describe.
-- Josh
- Original Message -
From: "GARIL" <[EMAIL PROTECTED]>
To: "jQuery (English)"
Sent: Wednesday, October 01, 2008 1:12 PM
Subject: [jQuery] Re: form select...
Thank your for your answers b
Thank your for your answers but I don't want to set the value.
What I want to happen is to programmatically change the select into:
BEFORE AFTER
Select your favorite fruit: Select your favorite fruit:
Select your favorite fruit:
Apple
Orange
Pineapple
Banana
In the form above how do I programmatically set using jQuery the
Pineapple option as the selected default?
Beautiful! Thank you very much, Alex and BB.
On Sep 28, 7:32 am, BB <[EMAIL PROTECTED]> wrote:
> $("#fruits option:selected").get(0).index
I slowly discovered the jQuery is so great.
Hehe
I love it!
2008/9/28 BB <[EMAIL PROTECTED]>
>
> $("#fruits option:selected").get(0).index
>
> On 28 Sep., 08:33, GARIL <[EMAIL PROTECTED]> wrote:
> > Thank you. What's the code if I want the index of the selected item?
> >
> > On Sep 28, 12:53 am,
$("#fruits option:selected").get(0).index
On 28 Sep., 08:33, GARIL <[EMAIL PROTECTED]> wrote:
> Thank you. What's the code if I want the index of the selected item?
>
> On Sep 28, 12:53 am, Alex Weber <[EMAIL PROTECTED]> wrote:
>
> > $('#fruits').val()
>
> > On Sep 28, 2:12 am, GARIL <[EMAIL PROT
Thank you. What's the code if I want the index of the selected item?
On Sep 28, 12:53 am, Alex Weber <[EMAIL PROTECTED]> wrote:
> $('#fruits').val()
>
> On Sep 28, 2:12 am, GARIL <[EMAIL PROTECTED]> wrote:
>
> > How do I use jQuery to determine which item was selected from the
> > forms below?
>
$('#fruits').val()
On Sep 28, 2:12 am, GARIL <[EMAIL PROTECTED]> wrote:
> How do I use jQuery to determine which item was selected from the
> forms below?
> Thank you for the help.
>
>
> Select your favorite fruit:
>
> Apple
> Orange
> Pineapple
> Banana
>
>
>
>
> Select your favorit
11 matches
Mail list logo