jQuery设置checkbox 为选中状态

1设置第一个checkbox 为选中值
$('input:checkbox:first').attr("checked",'checked');

或者
$('input:checkbox').eq(0).attr("checked",'true');

2、设置最后一个checkbox为选中值
$('input:checkbox:last').attr('checked', 'checked');

或者
$('input:checkbox:last').attr('checked', 'true');

3、根据索引值设置任意一个checkbox为选中值
$('input:checkbox).eq(索引值).attr('checked', 'true');索引值=0,1,2....

或者
$('input:checkbox').slice(1,2).attr('checked', 'true');

4、选中多个checkbox同时选中第1个和第2个的checkbox
$('input:checkbox').slice(0,2).attr('checked','true');

5、根据Value值设置checkbox为选中值
$("input:checkbox[value='1']").attr('checked','true');

6、设置某一个checkbox为选中值

选中checkbox:$(":checkbox").prop("checked", true);
取消选中:$(":checkbox").prop("checked", false);

参考:http://www.cnblogs.com/hs8888/archive/2016/05/23/5520511.html

原文地址:https://www.cnblogs.com/weimingxin/p/7141966.html