js获取多选框选择的值并拼接成字符串
在这里记录一下js获取多选框选择的值并拼接成字符串的方法,代码示例如下:
let str = ''; var obj = document.getElementsByName('identify') for (var i = 0; i < obj.length; i++) { if (obj[i].checked){ str += obj[i].value + "&" } } str = str.substring(0,str.length - 1) if(str != ''){ data.aiAbilityType = str }