Get values from multiple selections in SELECT

后端 未结 3 830
清歌不尽
清歌不尽 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:20

    var values = [];
    $('#my_select option:selected').each(function(i, selected){
        values[i] = $(selected).attr('value');
    });
    

提交回复
热议问题