var tog = false;// or true if they are checked on load$("a").click(function() { $("input[type=checkbox]").attr("checked",!tog);tog = !tog;});