Using jQuery Cookie to Save Flag State

How do you use the jQuery Cookie plugin to make sure the checkbox is checked, will be checked when the page is refreshed or exited and returned to the page?

+4
source share
1 answer

If you are using the $.cookie jQuery plugin ...

 var checkbox = $('#your-form :checkbox:first'), checkboxCookieName = 'checkbox-state'; checkbox.prop('checked', +$.cookie(checkboxCookieName)); checkbox.click(function() { $.cookie(checkboxCookieName, +this.checked); }); 
+4
source

Source: https://habr.com/ru/post/1393088/


All Articles