按值设置选择选项“已选择” - Set select option 'selected', by value

问题:

I have a select field with some options in it. 我有一个select字段,其中包含一些选项。 Now I need to select one of those options with jQuery. 如今我须要使用jQuery选择其中一个options But how can I do that when I only know the value of the option that must be selected? 可是当我只知道必须选择的optionvalue时,我怎么能这样作呢? this

I have the following HTML: 我有如下HTML: spa

<div class="id_100">
  <select>
    <option value="val1">Val 1</option>
    <option value="val2">Val 2</option>
    <option value="val3">Val 3</option>
  </select>
</div>

I need to select the option with value val2 . 我须要选择值为val2的选项。 How can this be done? 如何才能作到这一点? .net

Here's a demo page: http://jsfiddle.net/9Stxb/ 这是一个演示页面: http//jsfiddle.net/9Stxb/ code


解决方案:

参考一: https://stackoom.com/question/tzGo/按值设置选择选项-已选择
参考二: https://oldbug.net/q/tzGo/Set-select-option-selected-by-value
相关文章
相关标签/搜索