check all and uncheck all check boxes

check all and uncheck all check boxes

I need to be able to click on the button btn and select all check boxes,
then click on it again and it will uncheck all. but my code below will
only check all and uncheck all once. why does it stop working?
<script>
$('document').ready(function(){
$("#btn").on("click", function () {
var $checkbox = $(".checkBoxClass");
$checkbox.attr('checked', !$checkbox.attr('checked'));
});
});
</script>
<span id="btn">btn</span><br /><br />
<input type="checkbox" class="checkBoxClass" id="Checkbox1" />
<br />
<input type="checkbox" class="checkBoxClass" id="Checkbox2" />
<br />
<input type="checkbox" class="checkBoxClass" id="Checkbox3" />
<br />
<input type="checkbox" class="checkBoxClass" id="Checkbox4" />
<br />
<input type="checkbox" class="checkBoxClass" id="Checkbox5" />
<br />