0

I am developing a Web application. In my application, I am trying to select multiple options for the select dropdown using JavaScript.

This is my HTML

<select id="my-dropdown"
        name="select_locations"
        multiple="multiple"
        class="my-select-control">
        //options are here
</select>

This is my JavaScript

let dropDown = document.getElementById('my-dropdown');
dropDown.options[0].selected = true
dropDown.options[1].selected = true

But it is not selecting the options. How can I select multiple options?

Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

0 Answers0