I want to save the checkbox input checked in cookies. But my code does not work.
if (!$.cookie("checked")) {
$.cookie('checked' ,false);
}
var checked1 = $.cookie('checked');
$('input[type=checkbox]').attr('checked', checked1);
$('input[type=checkbox]').change(function () {
if (this.checked) {
$(this).attr('checked', true);
$.cookie('checked', 'true');
} if (!this.checked) {
$(this).attr('checked', false);
$.cookie('checked', false);
}
});