$(document).ready(function(){
var idsstr = "";
var isc = "";
$("#a input[name=chkId]").each(function(){ //遍历table里的全部checkbox
idsstr += $(this).val() + ","; //获取所有checkbox的值
if($(this).attr("checked")) //如果被选中
isc += $(this).val() + ","; //获取被选中的值
});
if(idsstr.length > 0) //如果获取到
idsstr = idsstr.substring(0, idsstr.length - 1); //把最后一个逗号去掉
if(isc.length > 0) //如果获取到
isc = isc.substring(0, isc.length - 1); //把最后一个逗号去掉
alert("所有checkbox的值:" + idsstr);
alert("被选中checkbox的值:" + isc);
});
<input type="checkbox" class="flow" value="">
if(
$(
".flow:checked").length>0){
var flows =
"";
$(
".flow:checked").each(function(){
flows+=
$(
this).
val()+
",";
})
;
flows = flows.
substring(
0,flows.
length-
1)
;
}
转载请注明原文地址: https://www.6miu.com/read-66768.html