$("#selectAll").click(function(){
if($(this).text()=='全选'){
$(":checkbox").attr("checked",true);
$("#selectAll").text("取消");
}else{
$(":checkbox").removeAttr("checked");
$("#selectAll").text('全选');
}
});
<a href="#" id="selectAll" >全选</a>
<input type="checkbox" />
<input type="checkbox" />