按值设置选择选项 “已选择”

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

答案

$("div.id_100 select").val("val2");
$('.id_100 option[value=val2]').attr('selected','selected');
$("#select_id").val("val2").change();
$('.id_100 option')
     .removeAttr('selected')
     .filter('[value=val1]')
         .attr('selected', true)
<select name="contribution_status_id" id="contribution_status_id" class="form-select">
    <option value="1">Completed</option>
    <option value="2">Pending</option>
    <option value="3">Cancelled</option>
    <option value="4">Failed</option>
    <option value="5">In Progress</option>
    <option value="6">Overdue</option>
    <option value="7">Refunded</option>
$('#contribution_status_id').val("2");
$("div.id_100").val("val2").change();
$('div.id_100  option[value="val2"]').prop("selected", true);

$('id_100').val('val2');
$('.id_100 option').each(function() {
    if($(this).val() == 'val2') {
        $(this).prop("selected", true);
    }
});
$("div.id_100 > select > option[value=" + value + "]").prop("selected",true);
$("div.id_100 option:selected").prop("selected",false);
$("div.id_100 option[value=" + value + "]")
        .prop("selected",true);
<select name="ukuran" id="idUkuran">
    <option value="1000">pilih ukuran</option>
    <option value="11">M</option>
    <option value="12">L</option>
    <option value="13">XL</option>
</select>
$('#idUkuran').val(11).change();
$("div.id_100 select").val("val2").change();