I want to save my checkbox value dynamically. When i check a specific one , all checkboxes are checked.Used target but did not work. Any ideas? JSFIDDLE
var data = localStorage.getItem("checkbox");
if (data) {
$("input[name='checkbox-name']").attr("checked", "checked");
}
$(document).on('change', "input[name='checkbox-name']", function (e) {
var target = $(e.target );
if (target.is(":checked")) {
localStorage.setItem("checkbox", 1);
} else {
localStorage.removeItem("checkbox");
}
});
Aucun commentaire:
Enregistrer un commentaire