FlyingCat
FlyingCat

Reputation: 14250

Select the option based on the value passed in

I am trying to select the dropdown menu to the certain option when I click a button

I have

Html

   <select id='selectmenu'>
    <option>
    1
    </option>
    <option>
    2
    </option>
    <option>
    3
    </option>   

    </select>

    <a id='click'>click</a>

Jquery

  $('#click').click(function(){

      var option=3;
      //I want the select dropdown menu to select option 3 when I click the button. 
      //$('#selectmenu').select()  //I think it will be something like this....

    })

Thanks for the help!

Upvotes: 0

Views: 51

Answers (1)

Naftali
Naftali

Reputation: 146302

$('#selectmenu').val(3); //p00f!

Upvotes: 5

Related Questions