Help to modify the code! I'm just learning, don't scold too much ...
- there are checkboxes - id1 ... id6, as well as value, which can change
we get the values of id and value:
var id = this.getAttribute('id'); var value = this.getAttribute('value');
the task is to check the checkboxes, if the mark is set, make a selection - categoryFilter('other'+ id, value);
if there is no mark - categoryFilter('other'+ id,'');
everything works, but when you refresh the page, the sample is saved, and the checkbox doesn’t have any marks, as I understand it, you need to use a cookie, then I’ve got a stub ... help the beginner
I do not understand how to save data and how to use it later !?
jQuery(document).ready(function (){ $('input[type="checkbox"]').on('change', function() { var id = this.getAttribute('id'); var value = this.getAttribute('value'); if(id == undefined) return; if(this.checked) { categoryFilter('other' + id, value); } else { categoryFilter('other' + id,''); } }); });