$("form #checkAll").click(function(){
var checkboxName ="checkbox1",AllId = $(this).attr("id")
$("input:checkbox[name="+checkboxName+"]").each(function(){
$(this).prop("checked",$("#"+AllId).prop("checked")||false)
})
})
<form>
<input type="checkbox" name="checkbox1" id="checkAll"/>
<input type="checkbox" name="checkbox1" value="1"/>
<input type="checkbox" name="checkbox1" value="2"/>