Get value of multiselect box using jQuery or pure JS

前端 未结 6 1282
傲寒
傲寒 2020-12-03 02:11

In the code shown below, how to get the values of multiselect box in function val() using jQuery or pure JavaScript?



        
6条回答
  •  孤街浪徒
    2020-12-03 03:12

    the val function called from the select will return an array if its a multiple. $('select#my_multiselect').val() will return an array of the values for the selected options - you dont need to loop through and get them yourself.

提交回复
热议问题