复选框全选

var checked = false;
$('#checkAll').click(function() {
checked = !checked;
$('input').prop("checked",checked);
var $subBox = $('#postList').find('input');
$subBox.click(function(){
$("#checkAll").attr("checked",$subBox.length == $("#postList input:checked").length ? true : false);
});
});

 

获取选中复选框的值

$('#postList').find('input[type="checkbox"]').each(function(){
if($(this).prop('checked')){
idList+=$(this).val()+',';
}
});

 

posted on 2017-05-12 14:21  xfdyl  阅读(115)  评论(0编辑  收藏  举报