jquery获取所有选中的checkbox实现代码

获取所有name为spCodeId的checkbox

var spCodesTemp = "";
  $('input:checkbox[name=spCodeId]:checked').each(function(i){
  if(0==i){
  spCodesTemp = $(this).val();
  }else{
  spCodesTemp += (","+$(this).val());
  }
  });
  $("#txt_spCodes").val(spCodesTemp);

相关推荐