根据传入的值选择选项

时间:2012-12-04 21:41:19

标签: jquery

当我点击按钮

时,我试图选择某个选项的下拉菜单

我有

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....

    })

感谢您的帮助!

1 个答案:

答案 0 :(得分:5)

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