Reputation: 11861
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.
Upvotes: 0
Views: 57
Reputation: 382150
To select an option by index, you can do this :
$("#membershiptype").get(0).selectedIndex=1;
To select an option by value (the content of the option), you may use this :
$("#membershiptype").val('B');
Upvotes: 2
Reputation: 1468
You can assign the val() to the option value you want to be selected.
$('#membershiptype').val(valueToBeSelected);
Upvotes: 0