checkbox全选和反选

/*得到checkbox中所选择的客户Id */
function getSelectedIds(){
  var customerArr = [];
  if($("#allCheck").prop("checked")){
  $("input[name='hobby']").each(function(){
/* var customerId = $(this).val();
cu stomerArr += customerId+",";*/
customerArr.push($(this).val());
   });
  }else{
  $("input[name='hobby']").each(function(){
  if( $(this).prop("checked")){
/* var customerId = $(this).val();
cus tomerArr += customerId+",";*/
customerArr.push($(this).val());
}
   });
  }
  return customerArr.join(",");
}



<td><input type="checkbox" id="allCheck" name="allCheck" value="1">全选</td>



<td><input type="checkbox" name="selectCustomer" value="${qr.id}" ></td>

猜你喜欢

转载自1425068190.iteye.com/blog/2206517