获取多个checkbox的name="selected[]"所对应的value
如下:
<input type="checkbox" value="61" name="selected[]" />
<input type="checkbox" value="62" name="selected[]" />
<input type="checkbox" value="63" name="selected[]" />
<input type="checkbox" value="64" name="selected[]" />
<input type="checkbox" value="65" name="selected[]" />
var selected = “”;
var checkSelected = $(“input:checkbox[name=‘selected[]’]”);
for(var i=0; i<checkSelected.length; i++){
if(checkSelected[i].checked){
if(checkSelected[i].value != ‘’){
selected += “,” + checkSelected[i].value;
}
}
}
selected = selected.slice(1);
注意:使用slice截取第一个多余的 逗号