JQuery: Turn array input values into a string optimization

前端 未结 3 495
迷失自我
迷失自我 2020-12-18 12:20

using jQuery I have the following code:

var selectedIdsArray = $(\"#selectId option:selected\").map(function(){return this.value;});
var selectedIdsStr = $.m         


        
3条回答
  •  甜味超标
    2020-12-18 13:08

    You could change the second line like this:

    var selectedIdsStr = selectedIdsArray.get().join(',');
    

提交回复
热议问题