jquery操作checkBox 一次取消选中后不能再选中

$("input[type='checkbox']").each(function(){  
     $(this).attr("checked","checked");  
});  
$("input[type='checkbox']").each(function(){  
     $(this).attr("checked",true);  
});  

以上代码均可用实现,但存在取消选中后无效的情况

使用以下代码可以解决

$("input[type='checkbox']").each(function(){  
     this.checked=true;
}); 

(jquery1.9以上,checkbox attr不能重复操作)可使用prop代替

$(selector).prop("checked","checked");