jQuery checkbox values to comma separated list

后端 未结 4 872
南方客
南方客 2021-01-04 03:00

I have several checkboxes with a name array and I want the output of the checked boxes to be a variable with a comma separated list.



        
4条回答
  •  無奈伤痛
    2021-01-04 03:40

    var valuesArray = $('input[name="valuehere"]:checked').map(function () {  
            return this.value;
            }).get().join(",");
    

    works for me always

提交回复
热议问题