0

I am trying to select a certain value in my dropdown via jquery..I tried this..

$("#membershiptype").val(1).selected;

it doesnt work..I am clearly over my head here as I am inexperience in jquery.

2 Answers 2

2

To select an option by index, you can do this :

$("#membershiptype").get(0).selectedIndex=1;

Demonstration

To select an option by value (the content of the option), you may use this :

$("#membershiptype").val('B');​

Demonstration

Sign up to request clarification or add additional context in comments.

Comments

0

You can assign the val() to the option value you want to be selected.

$('#membershiptype').val(valueToBeSelected);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.