Get values from multiple selections in SELECT

后端 未结 3 850
清歌不尽
清歌不尽 2021-01-14 04:33

I have a selection box that allows you to select multiple options. I need to access all the selected values with JavaScript - possible a array of values?

3条回答
  •  攒了一身酷
    2021-01-14 05:31

    This is the best way to get an array of the selected values back:

    $("#mySelect").val(); // Return an array of the selected options values
    

    This assumes that multiple="mutliple" and size is greater than one on the select element.

提交回复
热议问题