$('#attr').on('click', function() {
var checked = $('#checkbox').is(':checked');
$('#checkbox').attr('checked', !checked);
});
$('#prop').on('click', function() {
var checked = $('#checkbox').is(':checked');
$('#checkbox').prop('checked', !checked);
});
<div>
<input id="checkbox" type="checkbox">
<button id="attr">attr</button>
<button id="prop">prop</button>
</div>