So I have a select2 Multiple select box (dropdown) like the following:
<script type="text/javascript">
$(".js-example-basic-multiple").select2();
</script>
<select id="selector" class="js-example-basic-multiple" multiple="multiple">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
How can I use jquery to make certain options selected?
Thanks
edit:
I've tried this:
$("#selector option[value='AL']").attr("selected", "selected");
I want to choose from values that are already in the dropdown. I don't want to add new values that aren't already there.
So I want certain values to already be selected.