0

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.

Stacker
  • 113
  • 9

1 Answers1

0

I got the answer, it is:

$('#IDOFSELECTBOX').val("").change();

My internet went down so couldn't update. thanks for help

Stacker
  • 113
  • 9