YUYISHARE 2014-02-13
代码如下:
jQuery(function($){ 
$("input[name='key']:checkbox").click(function(){ 
var ids = ''; 
var flag = 0; 
$("#ids").attr("value",ids); 
$("input[name='key']:checkbox").each(function(){ 
if (true == $(this).attr("checked")) { 
ids += $(this).attr('value')+','; 
flag += 1; 
} 
}); 
if(0 < flag) { 
$("#ids").attr("value",ids); 
return true; 
}else { 
alert('请至少选择一项!'); 
return false; 
} 
}); 
}); 代码如下:
$("input[name='key']:checkbox").each(function(){ 
if (true == $(this).attr("checked")) { 
ids += $(this).attr('value')+','; 
} 
});