$(function(){
// 元素checkbox
var aChecked = $(‘.checkGoods‘);
// 全选
var oAllSelected = $(‘#checkAll‘);
oAllSelected.click(function() {
var $this = $(this);
if( $this.prop(‘checked‘) ) {
aChecked.each(function() {
$(this).prop(‘checked‘, true);
});
} else {
aChecked.each(function() {
$(this).prop(‘checked‘, false);
});
}
});
})
aChecked.each(function() {
$(this).prop(‘checked‘, !$(this).prop(‘checked‘));
});
原文:http://www.cnblogs.com/zsongs/p/5562531.html