如果您知道索引、值或文本。如果您没有直接引用的ID。

这、这和这都是有用的答案。

示例标记

<div class="selDiv">
  <select class="opts">
    <option selected value="DEFAULT">Default</option>
    <option value="SEL1">Selection 1</option>
    <option value="SEL2">Selection 2</option>
  </select>
</div>

当前回答

按值计算,jQuery1.7对我有用的代码如下:

$('#id option[value=theOptionValue]').prop('selected', 'selected').change();

其他回答

使用jquery-2.1.4,我找到了以下适合我的答案:

$('#MySelectionBox').val(123).change();

如果您有字符串值,请尝试以下操作:

$('#MySelectionBox').val("extra thing").change();

其他例子对我来说不起作用,所以我要加上这个答案。

我在以下位置找到了原始答案:https://forum.jquery.com/topic/how-to-dynamically-select-option-in-dropdown-menu

当我知道列表的索引时,我使用这个。

$("#yourlist :nth(1)").prop("selected","selected").change();

这允许列表更改,并触发更改事件。“:n(n)”从索引0开始计数

完全可以,尝试以下方法

对于正常选择选项

<script>    
    $(document).ready(function() {
    $("#id").val('select value here');
       });
        </script>

对于选择2选项,需要使用触发器选项

<script>    
        $(document).ready(function() {
        $("#id").val('select value here').trigger('change');
           });
            </script>

试试这个

您只需使用select字段id而不是#id(即#select_name)

使用选择选项值代替选项值

 <script>
    $(document).ready(function() {
$("#id option[value='option value']").attr('selected',true);
   });
    </script>

您可以命名select并使用此选项:

$("select[name='theNameYouChose']").find("option[value='theValueYouWantSelected']").attr("selected",true);

它应该选择所需的选项。